• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jreleaser / jreleaser / #558

08 Dec 2025 02:56PM UTC coverage: 48.239% (+0.02%) from 48.215%
#558

push

github

aalmiray
feat(core): warn when a name template cannot be resolved

Closes #1960

Closes #1961

299 of 573 new or added lines in 133 files covered. (52.18%)

4 existing lines in 4 files now uncovered.

26047 of 53996 relevant lines covered (48.24%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.51
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/packagers/BrewPackager.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 *
4
 * Copyright 2020-2025 The JReleaser authors.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     https://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
package org.jreleaser.model.internal.packagers;
19

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.Active;
22
import org.jreleaser.model.Stereotype;
23
import org.jreleaser.model.internal.JReleaserContext;
24
import org.jreleaser.model.internal.common.AbstractModelObject;
25
import org.jreleaser.model.internal.common.Artifact;
26
import org.jreleaser.model.internal.common.Domain;
27
import org.jreleaser.model.internal.distributions.Distribution;
28
import org.jreleaser.mustache.TemplateContext;
29
import org.jreleaser.util.PlatformUtils;
30

31
import java.util.ArrayList;
32
import java.util.LinkedHashMap;
33
import java.util.LinkedHashSet;
34
import java.util.List;
35
import java.util.Map;
36
import java.util.Objects;
37
import java.util.Set;
38

39
import static java.util.Collections.emptySet;
40
import static java.util.Collections.unmodifiableList;
41
import static java.util.Collections.unmodifiableMap;
42
import static java.util.Collections.unmodifiableSet;
43
import static java.util.stream.Collectors.toList;
44
import static org.jreleaser.model.Constants.SKIP_CASK_DISPLAY_NAME_TRANSFORM;
45
import static org.jreleaser.model.Distribution.DistributionType.BINARY;
46
import static org.jreleaser.model.Distribution.DistributionType.FLAT_BINARY;
47
import static org.jreleaser.model.Distribution.DistributionType.JAVA_BINARY;
48
import static org.jreleaser.model.Distribution.DistributionType.JLINK;
49
import static org.jreleaser.model.Distribution.DistributionType.NATIVE_IMAGE;
50
import static org.jreleaser.model.Distribution.DistributionType.NATIVE_PACKAGE;
51
import static org.jreleaser.model.Distribution.DistributionType.SINGLE_JAR;
52
import static org.jreleaser.model.JReleaserOutput.nag;
53
import static org.jreleaser.model.api.packagers.BrewPackager.SKIP_BREW;
54
import static org.jreleaser.model.api.packagers.BrewPackager.TYPE;
55
import static org.jreleaser.mustache.Templates.resolveTemplate;
56
import static org.jreleaser.util.CollectionUtils.setOf;
57
import static org.jreleaser.util.FileType.DMG;
58
import static org.jreleaser.util.FileType.JAR;
59
import static org.jreleaser.util.FileType.PKG;
60
import static org.jreleaser.util.FileType.ZIP;
61
import static org.jreleaser.util.StringUtils.getClassNameForLowerCaseHyphenSeparatedName;
62
import static org.jreleaser.util.StringUtils.getNaturalName;
63
import static org.jreleaser.util.StringUtils.isBlank;
64
import static org.jreleaser.util.StringUtils.isFalse;
65
import static org.jreleaser.util.StringUtils.isNotBlank;
66

67
/**
68
 * @author Andres Almiray
69
 * @since 0.1.0
70
 */
71
public final class BrewPackager extends AbstractRepositoryPackager<org.jreleaser.model.api.packagers.BrewPackager, BrewPackager> {
72
    private static final Map<org.jreleaser.model.Distribution.DistributionType, Set<String>> SUPPORTED = new LinkedHashMap<>();
1✔
73
    private static final long serialVersionUID = -2068963278096348674L;
74

75
    static {
76
        Set<String> extensions = setOf(ZIP.extension());
1✔
77
        SUPPORTED.put(NATIVE_IMAGE, extensions);
1✔
78
        SUPPORTED.put(BINARY, extensions);
1✔
79
        SUPPORTED.put(JAVA_BINARY, extensions);
1✔
80
        SUPPORTED.put(JLINK, extensions);
1✔
81
        SUPPORTED.put(NATIVE_PACKAGE, setOf(ZIP.extension(), DMG.extension(), PKG.extension()));
1✔
82
        SUPPORTED.put(SINGLE_JAR, setOf(JAR.extension()));
1✔
83
        SUPPORTED.put(FLAT_BINARY, emptySet());
1✔
84
    }
1✔
85

86
    private final List<Dependency> dependencies = new ArrayList<>();
1✔
87
    private final List<String> livecheck = new ArrayList<>();
1✔
88
    private final Set<String> requireRelative = new LinkedHashSet<>();
1✔
89
    private final HomebrewRepository repository = new HomebrewRepository();
1✔
90
    private final Cask cask = new Cask();
1✔
91

92
    private String formulaName;
93
    private String cachedFormulaName;
94
    private String downloadStrategy;
95
    private Boolean multiPlatform;
96

97
    @JsonIgnore
1✔
98
    private final org.jreleaser.model.api.packagers.BrewPackager immutable = new org.jreleaser.model.api.packagers.BrewPackager() {
1✔
99
        private static final long serialVersionUID = -4959973991768535895L;
100

101
        @Override
102
        public String getFormulaName() {
103
            return formulaName;
×
104
        }
105

106
        @Override
107
        public String getDownloadStrategy() {
108
            return downloadStrategy;
×
109
        }
110

111
        @Override
112
        public boolean isMultiPlatform() {
113
            return BrewPackager.this.isMultiPlatform();
×
114
        }
115

116
        @Override
117
        public org.jreleaser.model.api.packagers.PackagerRepository getRepository() {
118
            return repository.asImmutable();
×
119
        }
120

121
        @Override
122
        public org.jreleaser.model.api.packagers.PackagerRepository getTap() {
123
            return getRepository();
×
124
        }
125

126
        @Override
127
        public Cask getCask() {
128
            return cask.asImmutable();
×
129
        }
130

131
        @Override
132
        public List<String> getLivecheck() {
133
            return unmodifiableList(livecheck);
×
134
        }
135

136
        @Override
137
        public Set<String> getRequireRelative() {
138
            return unmodifiableSet(requireRelative);
×
139
        }
140

141
        @Override
142
        public org.jreleaser.model.api.packagers.PackagerRepository getPackagerRepository() {
143
            return getRepository();
×
144
        }
145

146
        @Override
147
        public org.jreleaser.model.api.common.CommitAuthor getCommitAuthor() {
148
            return BrewPackager.this.getCommitAuthor().asImmutable();
×
149
        }
150

151
        @Override
152
        public String getTemplateDirectory() {
153
            return BrewPackager.this.getTemplateDirectory();
×
154
        }
155

156
        @Override
157
        public List<String> getSkipTemplates() {
158
            return unmodifiableList(BrewPackager.this.getSkipTemplates());
×
159
        }
160

161
        @Override
162
        public String getType() {
163
            return BrewPackager.this.getType();
×
164
        }
165

166
        @Override
167
        public String getDownloadUrl() {
168
            return BrewPackager.this.getDownloadUrl();
×
169
        }
170

171
        @Override
172
        public boolean supportsPlatform(String platform) {
173
            return BrewPackager.this.supportsPlatform(platform);
×
174
        }
175

176
        @Override
177
        public boolean supportsDistribution(org.jreleaser.model.Distribution.DistributionType distributionType) {
178
            return BrewPackager.this.supportsDistribution(distributionType);
×
179
        }
180

181
        @Override
182
        public Set<String> getSupportedFileExtensions(org.jreleaser.model.Distribution.DistributionType distributionType) {
183
            return BrewPackager.this.getSupportedFileExtensions(distributionType);
×
184
        }
185

186
        @Override
187
        public Set<Stereotype> getSupportedStereotypes() {
188
            return BrewPackager.this.getSupportedStereotypes();
×
189
        }
190

191
        @Override
192
        public boolean isSnapshotSupported() {
193
            return BrewPackager.this.isSnapshotSupported();
×
194
        }
195

196
        @Override
197
        public boolean isContinueOnError() {
198
            return BrewPackager.this.isContinueOnError();
×
199
        }
200

201
        @Override
202
        public boolean isSkipPublishing() {
203
            return BrewPackager.this.isSkipPublishing();
×
204
        }
205

206
        @Override
207
        public Active getActive() {
208
            return BrewPackager.this.getActive();
×
209
        }
210

211
        @Override
212
        public boolean isEnabled() {
213
            return BrewPackager.this.isEnabled();
×
214
        }
215

216
        @Override
217
        public Map<String, Object> asMap(boolean full) {
218
            return unmodifiableMap(BrewPackager.this.asMap(full));
×
219
        }
220

221
        @Override
222
        public String getPrefix() {
223
            return BrewPackager.this.prefix();
×
224
        }
225

226
        @Override
227
        public Map<String, Object> getExtraProperties() {
228
            return unmodifiableMap(BrewPackager.this.getExtraProperties());
×
229
        }
230
    };
231

232
    public BrewPackager() {
233
        super(TYPE);
1✔
234
        this.cask.setOwner(this);
1✔
235
    }
1✔
236

237
    @Override
238
    public org.jreleaser.model.api.packagers.BrewPackager asImmutable() {
239
        return immutable;
1✔
240
    }
241

242
    @Override
243
    public void merge(BrewPackager source) {
244
        super.merge(source);
1✔
245
        this.formulaName = merge(this.formulaName, source.formulaName);
1✔
246
        this.multiPlatform = merge(this.multiPlatform, source.multiPlatform);
1✔
247
        this.downloadStrategy = merge(this.downloadStrategy, source.downloadStrategy);
1✔
248
        setRepository(source.repository);
1✔
249
        setDependenciesAsList(merge(this.dependencies, source.dependencies));
1✔
250
        setLivecheck(merge(this.livecheck, source.livecheck));
1✔
251
        setRequireRelative(merge(this.requireRelative, source.requireRelative));
1✔
252
        setCask(source.cask);
1✔
253
    }
1✔
254

255
    public String getResolvedFormulaName(JReleaserContext context) {
256
        if (isBlank(cachedFormulaName)) {
1✔
257
            cachedFormulaName = resolveTemplate(context.getLogger(), formulaName, context.fullProps());
1✔
258
            cachedFormulaName = getClassNameForLowerCaseHyphenSeparatedName(cachedFormulaName);
1✔
259
        }
260
        return cachedFormulaName;
1✔
261
    }
262

263
    public String getResolvedFormulaName(JReleaserContext context, TemplateContext props) {
264
        if (isBlank(cachedFormulaName)) {
1✔
NEW
265
            cachedFormulaName = resolveTemplate(context.getLogger(), formulaName, props);
×
266
            cachedFormulaName = getClassNameForLowerCaseHyphenSeparatedName(cachedFormulaName);
×
267
        } else if (cachedFormulaName.contains("{{")) {
1✔
NEW
268
            cachedFormulaName = resolveTemplate(context.getLogger(), cachedFormulaName, props);
×
269
            cachedFormulaName = getClassNameForLowerCaseHyphenSeparatedName(cachedFormulaName);
×
270
        }
271
        return cachedFormulaName;
1✔
272
    }
273

274
    public String getFormulaName() {
275
        return formulaName;
1✔
276
    }
277

278
    public void setFormulaName(String formulaName) {
279
        this.formulaName = formulaName;
1✔
280
    }
1✔
281

282
    public String getDownloadStrategy() {
283
        return downloadStrategy;
1✔
284
    }
285

286
    public void setDownloadStrategy(String downloadStrategy) {
287
        this.downloadStrategy = downloadStrategy;
1✔
288
    }
1✔
289

290
    public boolean isMultiPlatform() {
291
        return null != multiPlatform && multiPlatform;
1✔
292
    }
293

294
    public void setMultiPlatform(Boolean multiPlatform) {
295
        this.multiPlatform = multiPlatform;
1✔
296
    }
1✔
297

298
    public boolean isMultiPlatformSet() {
299
        return null != multiPlatform;
1✔
300
    }
301

302
    public HomebrewRepository getRepository() {
303
        return repository;
1✔
304
    }
305

306
    public void setRepository(HomebrewRepository repository) {
307
        this.repository.merge(repository);
1✔
308
    }
1✔
309

310
    @Deprecated
311
    public HomebrewRepository getTap() {
312
        return getRepository();
×
313
    }
314

315
    @Deprecated
316
    public void setTap(HomebrewRepository repository) {
317
        nag("brew.tap is deprecated since 1.8.0 and will be removed in 2.0.0. Use brew.repository instead");
1✔
318
        setRepository(repository);
1✔
319
    }
1✔
320

321
    public Cask getCask() {
322
        return cask;
1✔
323
    }
324

325
    public void setCask(Cask cask) {
326
        this.cask.merge(cask);
1✔
327
        this.cask.setOwner(this);
1✔
328
    }
1✔
329

330
    public void setDependencies(Map<String, String> dependencies) {
331
        if (null == dependencies || dependencies.isEmpty()) {
×
332
            return;
×
333
        }
334
        this.dependencies.clear();
×
335
        dependencies.forEach(this::addDependency);
×
336
    }
×
337

338
    public List<Dependency> getDependenciesAsList() {
339
        return dependencies;
1✔
340
    }
341

342
    public void setDependenciesAsList(List<Dependency> dependencies) {
343
        if (null == dependencies || dependencies.isEmpty()) {
1✔
344
            return;
1✔
345
        }
346
        this.dependencies.clear();
×
347
        this.dependencies.addAll(dependencies);
×
348
    }
×
349

350
    public void addDependencies(Map<String, String> dependencies) {
351
        if (null == dependencies || dependencies.isEmpty()) {
×
352
            return;
×
353
        }
354
        dependencies.forEach(this::addDependency);
×
355
    }
×
356

357
    public void addDependency(String key, String value) {
358
        dependencies.add(new Dependency(key, value));
×
359
    }
×
360

361
    public void addDependency(String key) {
362
        dependencies.add(new Dependency(key));
×
363
    }
×
364

365
    public List<String> getLivecheck() {
366
        return livecheck;
1✔
367
    }
368

369
    public void setLivecheck(List<String> livecheck) {
370
        this.livecheck.clear();
1✔
371
        this.livecheck.addAll(livecheck);
1✔
372
    }
1✔
373

374
    public boolean hasLivecheck() {
375
        return !livecheck.isEmpty();
1✔
376
    }
377

378
    public Set<String> getRequireRelative() {
379
        return requireRelative;
1✔
380
    }
381

382
    public void setRequireRelative(Set<String> requireRelative) {
383
        this.requireRelative.clear();
1✔
384
        this.requireRelative.addAll(requireRelative);
1✔
385
    }
1✔
386

387
    @Override
388
    protected void asMap(boolean full, Map<String, Object> props) {
389
        super.asMap(full, props);
1✔
390
        props.put("formulaName", formulaName);
1✔
391
        props.put("downloadStrategy", downloadStrategy);
1✔
392
        props.put("multiPlatform", isMultiPlatform());
1✔
393
        props.put("repository", repository.asMap(full));
1✔
394
        props.put("dependencies", dependencies);
1✔
395
        props.put("livecheck", livecheck);
1✔
396
        props.put("requireRelative", requireRelative);
1✔
397
        props.put("cask", cask.asMap(full));
1✔
398
    }
1✔
399

400
    @Override
401
    public RepositoryTap getRepositoryTap() {
402
        return getRepository();
1✔
403
    }
404

405
    public PackagerRepository getPackagerRepository() {
406
        return getRepository();
×
407
    }
408

409
    @Override
410
    public boolean supportsPlatform(String platform) {
411
        if (isMultiPlatform()) {
1✔
412
            return isBlank(platform) || PlatformUtils.isMac(platform) || PlatformUtils.isLinux(platform) &&
1✔
413
                !PlatformUtils.isAlpineLinux(platform);
1✔
414
        }
415
        return isBlank(platform) || PlatformUtils.isMac(platform);
×
416
    }
417

418
    @Override
419
    public boolean supportsDistribution(org.jreleaser.model.Distribution.DistributionType distributionType) {
420
        return SUPPORTED.containsKey(distributionType);
1✔
421
    }
422

423
    @Override
424
    public Set<String> getSupportedFileExtensions(org.jreleaser.model.Distribution.DistributionType distributionType) {
425
        return unmodifiableSet(SUPPORTED.getOrDefault(distributionType, emptySet()));
1✔
426
    }
427

428
    @Override
429
    public List<Artifact> resolveCandidateArtifacts(JReleaserContext context, Distribution distribution) {
430
        List<Artifact> candidateArtifacts = super.resolveCandidateArtifacts(context, distribution);
1✔
431

432
        if (cask.isEnabled()) {
1✔
433
            return candidateArtifacts.stream()
×
434
                .filter(artifact -> isBlank(artifact.getPlatform()) || PlatformUtils.isMac(artifact.getPlatform()))
×
435
                .collect(toList());
×
436
        }
437

438
        return candidateArtifacts;
1✔
439
    }
440

441
    @Override
442
    protected boolean isNotSkipped(Artifact artifact) {
443
        return isFalse(artifact.getExtraProperties().get(SKIP_BREW));
1✔
444
    }
445

446
    public static final class Dependency {
447
        private final String key;
448
        private final String value;
449

450
        private Dependency(String key) {
451
            this(key, null);
×
452
        }
×
453

454
        private Dependency(String key, String value) {
×
455
            this.key = key;
×
456
            this.value = isBlank(value) || "null".equalsIgnoreCase(value) ? null : value;
×
457
        }
×
458

459
        public String getKey() {
460
            return key;
×
461
        }
462

463
        public String getValue() {
464
            return value;
×
465
        }
466

467
        @Override
468
        public String toString() {
469
            StringBuilder formatted = new StringBuilder();
×
470
            if (key.startsWith(":")) {
×
471
                formatted.append(key);
×
472
            } else {
473
                formatted.append("\"")
×
474
                    .append(key)
×
475
                    .append("\"");
×
476
            }
477
            if (isNotBlank(value)) {
×
478
                formatted.append(" => \"")
×
479
                    .append(value)
×
480
                    .append("\"");
×
481
            }
482
            return formatted.toString();
×
483
        }
484

485
        @Override
486
        public boolean equals(Object o) {
487
            if (this == o) return true;
×
488
            if (null == o || getClass() != o.getClass()) return false;
×
489
            Dependency that = (Dependency) o;
×
490
            return key.equals(that.key);
×
491
        }
492

493
        @Override
494
        public int hashCode() {
495
            return Objects.hash(key);
×
496
        }
497
    }
498

499
    public static final class HomebrewRepository extends PackagerRepository {
500
        private static final long serialVersionUID = 5221738236173499392L;
501

502
        public HomebrewRepository() {
503
            super("homebrew", "homebrew-tap");
1✔
504
        }
1✔
505
    }
506

507
    public static final class Cask extends AbstractModelObject<Cask> implements Domain {
1✔
508
        private static final long serialVersionUID = -8511530978828845393L;
509

510
        private final List<CaskItem> uninstall = new ArrayList<>();
1✔
511
        private final List<CaskItem> zap = new ArrayList<>();
1✔
512
        private Boolean enabled;
513
        private String name;
514
        private String displayName;
515
        private String pkgName;
516
        private String appName;
517
        private String appcast;
518
        @JsonIgnore
519
        private BrewPackager owner;
520

521
        @JsonIgnore
1✔
522
        private final org.jreleaser.model.api.packagers.BrewPackager.Cask immutable = new org.jreleaser.model.api.packagers.BrewPackager.Cask() {
1✔
523
            private static final long serialVersionUID = 5862868849533321019L;
524

525
            private List<? extends org.jreleaser.model.api.packagers.BrewPackager.CaskItem> uninstall;
526
            private List<? extends org.jreleaser.model.api.packagers.BrewPackager.CaskItem> zap;
527

528
            @Override
529
            public boolean isEnabled() {
530
                return Cask.this.isEnabled();
×
531
            }
532

533
            @Override
534
            public String getName() {
535
                return name;
×
536
            }
537

538
            @Override
539
            public String getDisplayName() {
540
                return displayName;
×
541
            }
542

543
            @Override
544
            public String getPkgName() {
545
                return pkgName;
×
546
            }
547

548
            @Override
549
            public String getAppName() {
550
                return appName;
×
551
            }
552

553
            @Override
554
            public String getAppcast() {
555
                return appcast;
×
556
            }
557

558
            @Override
559
            public List<? extends org.jreleaser.model.api.packagers.BrewPackager.CaskItem> getUninstallItems() {
560
                if (null == uninstall) {
×
561
                    uninstall = Cask.this.uninstall.stream()
×
562
                        .map(CaskItem::asImmutable)
×
563
                        .collect(toList());
×
564
                }
565
                return uninstall;
×
566
            }
567

568
            @Override
569
            public List<? extends org.jreleaser.model.api.packagers.BrewPackager.CaskItem> getZapItems() {
570
                if (null == zap) {
×
571
                    zap = Cask.this.zap.stream()
×
572
                        .map(CaskItem::asImmutable)
×
573
                        .collect(toList());
×
574
                }
575
                return zap;
×
576
            }
577

578
            @Override
579
            public Map<String, Object> asMap(boolean full) {
580
                return unmodifiableMap(Cask.this.asMap(full));
×
581
            }
582
        };
583

584
        @JsonIgnore
585
        private String cachedCaskName;
586
        @JsonIgnore
587
        private String cachedDisplayName;
588
        @JsonIgnore
589
        private String cachedAppName;
590
        @JsonIgnore
591
        private String cachedPkgName;
592

593
        public org.jreleaser.model.api.packagers.BrewPackager.Cask asImmutable() {
594
            return immutable;
×
595
        }
596

597
        @Override
598
        public void merge(Cask source) {
599
            this.enabled = this.merge(this.enabled, source.enabled);
1✔
600
            this.name = this.merge(this.name, source.name);
1✔
601
            this.displayName = this.merge(this.displayName, source.displayName);
1✔
602
            this.pkgName = this.merge(this.pkgName, source.pkgName);
1✔
603
            this.appName = this.merge(this.appName, source.appName);
1✔
604
            this.appcast = this.merge(this.appcast, source.appcast);
1✔
605
            setUninstallItems(merge(this.uninstall, source.uninstall));
1✔
606
            setZapItems(merge(this.zap, source.zap));
1✔
607
        }
1✔
608

609
        public void setOwner(BrewPackager owner) {
610
            this.owner = owner;
1✔
611
        }
1✔
612

613
        public void enable() {
614
            this.enabled = true;
×
615
        }
×
616

617
        public void disable() {
618
            this.enabled = false;
1✔
619
        }
1✔
620

621

622
        public boolean isEnabled() {
623
            return null != enabled && enabled;
1✔
624
        }
625

626
        public void setEnabled(Boolean enabled) {
627
            this.enabled = enabled;
×
628
        }
×
629

630
        public boolean isEnabledSet() {
631
            return null != enabled;
1✔
632
        }
633

634
        public String getResolvedAppcast(JReleaserContext context, TemplateContext props) {
635
            if (isNotBlank(appcast)) {
×
NEW
636
                return resolveTemplate(context.getLogger(), appcast, props);
×
637
            }
638
            return appcast;
×
639
        }
640

641
        public String getResolvedCaskName(JReleaserContext context, TemplateContext props) {
642
            if (isBlank(cachedCaskName)) {
×
NEW
643
                cachedCaskName = resolveTemplate(context.getLogger(), name, props);
×
644
            } else if (cachedCaskName.contains("{{")) {
×
NEW
645
                cachedCaskName = resolveTemplate(context.getLogger(), cachedCaskName, props);
×
646
            }
647
            return cachedCaskName;
×
648
        }
649

650
        public String getResolvedDisplayName(JReleaserContext context, TemplateContext props) {
651
            if (isBlank(cachedDisplayName)) {
×
NEW
652
                cachedDisplayName = resolveTemplate(context.getLogger(), displayName, props);
×
653
                if (isFalse(owner.getExtraProperty(SKIP_CASK_DISPLAY_NAME_TRANSFORM))) {
×
654
                    cachedDisplayName = getNaturalName(getClassNameForLowerCaseHyphenSeparatedName(cachedDisplayName));
×
655
                }
656
            } else if (cachedDisplayName.contains("{{")) {
×
NEW
657
                cachedDisplayName = resolveTemplate(context.getLogger(), cachedDisplayName, props);
×
658
                if (isFalse(owner.getExtraProperty(SKIP_CASK_DISPLAY_NAME_TRANSFORM))) {
×
659
                    cachedDisplayName = getNaturalName(getClassNameForLowerCaseHyphenSeparatedName(cachedDisplayName));
×
660
                }
661
            }
662
            return cachedDisplayName;
×
663
        }
664

665
        public String getResolvedAppName(JReleaserContext context, TemplateContext props) {
666
            if (isBlank(cachedAppName)) {
×
NEW
667
                cachedAppName = resolveTemplate(context.getLogger(), appName, props);
×
668
            } else if (cachedAppName.contains("{{")) {
×
NEW
669
                cachedAppName = resolveTemplate(context.getLogger(), cachedAppName, props);
×
670
            }
671
            return cachedAppName;
×
672
        }
673

674
        public String getResolvedPkgName(JReleaserContext context, TemplateContext props) {
675
            if (isBlank(cachedPkgName)) {
×
NEW
676
                cachedPkgName = resolveTemplate(context.getLogger(), pkgName, props);
×
677
            } else if (cachedPkgName.contains("{{")) {
×
NEW
678
                cachedPkgName = resolveTemplate(context.getLogger(), cachedPkgName, props);
×
679
            }
680
            return cachedPkgName;
×
681
        }
682

683
        public String getName() {
684
            return name;
×
685
        }
686

687
        public void setName(String name) {
688
            this.name = name;
×
689
        }
×
690

691
        public String getDisplayName() {
692
            return displayName;
×
693
        }
694

695
        public void setDisplayName(String displayName) {
696
            this.displayName = displayName;
×
697
        }
×
698

699
        public String getPkgName() {
700
            return pkgName;
×
701
        }
702

703
        public void setPkgName(String pkgName) {
704
            this.pkgName = pkgName;
×
705
        }
×
706

707
        public String getAppName() {
708
            return appName;
×
709
        }
710

711
        public void setAppName(String appName) {
712
            this.appName = appName;
×
713
        }
×
714

715
        public String getAppcast() {
716
            return appcast;
×
717
        }
718

719
        public void setAppcast(String appcast) {
720
            this.appcast = appcast;
×
721
        }
×
722

723
        public List<CaskItem> getUninstallItems() {
724
            return uninstall;
×
725
        }
726

727
        void setUninstallItems(List<CaskItem> uninstall) {
728
            this.uninstall.clear();
1✔
729
            this.uninstall.addAll(uninstall);
1✔
730
        }
1✔
731

732
        public void setUninstall(Map<String, List<String>> uninstall) {
733
            this.uninstall.clear();
×
734
            uninstall.forEach((name, items) -> this.uninstall.add(new CaskItem(name, items)));
×
735
        }
×
736

737
        public void addUninstall(CaskItem item) {
738
            if (null != item) {
×
739
                this.uninstall.add(item);
×
740
            }
741
        }
×
742

743
        public boolean getHasUninstall() {
744
            return !uninstall.isEmpty();
×
745
        }
746

747
        public List<CaskItem> getZapItems() {
748
            return zap;
×
749
        }
750

751
        void setZapItems(List<CaskItem> zap) {
752
            this.zap.clear();
1✔
753
            this.zap.addAll(zap);
1✔
754
        }
1✔
755

756
        public void setZap(Map<String, List<String>> zap) {
757
            this.zap.clear();
×
758
            zap.forEach((name, items) -> this.zap.add(new CaskItem(name, items)));
×
759
        }
×
760

761
        public void addZap(CaskItem item) {
762
            if (null != item) {
×
763
                this.zap.add(item);
×
764
            }
765
        }
×
766

767
        public boolean getHasZap() {
768
            return !zap.isEmpty();
×
769
        }
770

771
        @Override
772
        public Map<String, Object> asMap(boolean full) {
773
            Map<String, Object> map = new LinkedHashMap<>();
1✔
774
            map.put("enabled", isEnabled());
1✔
775
            map.put("name", name);
1✔
776
            map.put("displayName", displayName);
1✔
777
            map.put("appName", appName);
1✔
778
            map.put("pkgName", pkgName);
1✔
779
            map.put("appcast", appcast);
1✔
780
            if (!uninstall.isEmpty()) {
1✔
781
                map.put("uninstall", uninstall.stream()
×
782
                    .map(CaskItem::asMap)
×
783
                    .collect(toList()));
×
784
            }
785
            if (!zap.isEmpty()) {
1✔
786
                map.put("zap", zap.stream()
×
787
                    .map(CaskItem::asMap)
×
788
                    .collect(toList()));
×
789
            }
790
            return map;
1✔
791
        }
792
    }
793

794
    public static final class CaskItem extends AbstractModelObject<CaskItem> implements Domain {
795
        private static final long serialVersionUID = -2577845359978097441L;
796

797
        private final List<String> items = new ArrayList<>();
×
798
        private String name;
799

800
        @JsonIgnore
×
801
        private final org.jreleaser.model.api.packagers.BrewPackager.CaskItem immutable = new org.jreleaser.model.api.packagers.BrewPackager.CaskItem() {
×
802
            private static final long serialVersionUID = -8230159341038906539L;
803

804
            @Override
805
            public String getName() {
806
                return name;
×
807
            }
808

809
            @Override
810
            public List<String> getItems() {
811
                return unmodifiableList(items);
×
812
            }
813

814
            @Override
815
            public Map<String, Object> asMap(boolean full) {
816
                return unmodifiableMap(CaskItem.this.asMap(full));
×
817
            }
818
        };
819

820
        public CaskItem(String name, List<String> items) {
×
821
            this.name = name;
×
822
            this.items.addAll(items);
×
823
        }
×
824

825
        public org.jreleaser.model.api.packagers.BrewPackager.CaskItem asImmutable() {
826
            return immutable;
×
827
        }
828

829
        public String getName() {
830
            return name;
×
831
        }
832

833
        public void setName(String name) {
834
            this.name = name;
×
835
        }
×
836

837
        public List<String> getItems() {
838
            return items;
×
839
        }
840

841
        public void setItems(List<String> items) {
842
            this.items.clear();
×
843
            this.items.addAll(items);
×
844
        }
×
845

846
        public boolean getHasItems() {
847
            return !items.isEmpty();
×
848
        }
849

850
        @Override
851
        public Map<String, Object> asMap(boolean full) {
852
            return asMap();
×
853
        }
854

855
        public Map<String, Object> asMap() {
856
            Map<String, Object> map = new LinkedHashMap<>();
×
857
            map.put(name, items);
×
858
            return map;
×
859
        }
860

861
        @Override
862
        public void merge(CaskItem source) {
863
            this.name = merge(this.name, source.name);
×
864
            setItems(merge(this.items, source.items));
×
865
        }
×
866
    }
867
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc