• 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

0.0
/core/jreleaser-model-impl/src/main/java/org/jreleaser/model/internal/tools/Jbang.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.tools;
19

20
import com.fasterxml.jackson.annotation.JsonIgnore;
21
import org.jreleaser.model.internal.JReleaserContext;
22
import org.jreleaser.model.internal.common.AbstractModelObject;
23
import org.jreleaser.model.internal.common.Domain;
24
import org.jreleaser.mustache.TemplateContext;
25

26
import java.util.ArrayList;
27
import java.util.LinkedHashMap;
28
import java.util.List;
29
import java.util.Map;
30

31
import static java.util.Collections.unmodifiableList;
32
import static java.util.Collections.unmodifiableMap;
33
import static java.util.stream.Collectors.toList;
34
import static org.jreleaser.mustache.Templates.resolveTemplate;
35
import static org.jreleaser.util.StringUtils.isNotBlank;
36

37
/**
38
 * @author Andres Almiray
39
 * @since 1.20.0
40
 */
41
public final class Jbang extends AbstractModelObject<Jbang> implements Domain {
×
42
    private static final long serialVersionUID = -5302165340574693085L;
43

44
    private final List<String> args = new ArrayList<>();
×
45
    private final List<String> jbangArgs = new ArrayList<>();
×
46
    private final List<String> trusts = new ArrayList<>();
×
47
    private String version;
48
    private String script;
49

50
    @JsonIgnore
×
51
    private final org.jreleaser.model.api.tools.Jbang immutable = new org.jreleaser.model.api.tools.Jbang() {
×
52
        private static final long serialVersionUID = -684610546142494357L;
53

54
        @Override
55
        public String getVersion() {
56
            return version;
×
57
        }
58

59
        @Override
60
        public String getScript() {
61
            return script;
×
62
        }
63

64
        @Override
65
        public List<String> getArgs() {
66
            return unmodifiableList(args);
×
67
        }
68

69
        @Override
70
        public List<String> getJbangArgs() {
71
            return unmodifiableList(jbangArgs);
×
72
        }
73

74
        @Override
75
        public List<String> getTrusts() {
76
            return unmodifiableList(trusts);
×
77
        }
78

79
        @Override
80
        public Map<String, Object> asMap(boolean full) {
81
            return unmodifiableMap(Jbang.this.asMap(full));
×
82
        }
83
    };
84

85
    public org.jreleaser.model.api.tools.Jbang asImmutable() {
86
        return immutable;
×
87
    }
88

89
    @Override
90
    public void merge(Jbang source) {
91
        this.version = merge(this.version, source.version);
×
92
        this.script = merge(this.script, source.script);
×
93
        setArgs(merge(this.args, source.args));
×
94
        setJbangArgs(merge(this.jbangArgs, source.jbangArgs));
×
95
        setTrusts(merge(this.trusts, source.trusts));
×
96
    }
×
97

98
    public boolean isSet() {
99
        return isNotBlank(script);
×
100
    }
101

102
    public String getResolvedScript(JReleaserContext context) {
103
        TemplateContext props = context.fullProps();
×
NEW
104
        context.getModel().getRelease().getReleaser().fillProps(props, context);
×
NEW
105
        return resolveTemplate(context.getLogger(), script, props);
×
106
    }
107

108
    public List<String> getResolvedArgs(JReleaserContext context) {
109
        TemplateContext props = context.fullProps();
×
NEW
110
        context.getModel().getRelease().getReleaser().fillProps(props, context);
×
111
        return args.stream()
×
NEW
112
            .map(s -> resolveTemplate(context.getLogger(), s, props))
×
NEW
113
            .collect(toList());
×
114
    }
115

116
    public List<String> getResolvedJbangArgs(JReleaserContext context) {
117
        TemplateContext props = context.fullProps();
×
NEW
118
        context.getModel().getRelease().getReleaser().fillProps(props, context);
×
119
        return jbangArgs.stream()
×
NEW
120
            .map(s -> resolveTemplate(context.getLogger(), s, props))
×
NEW
121
            .collect(toList());
×
122
    }
123

124
    public List<String> getResolvedTrusts(JReleaserContext context) {
125
        TemplateContext props = context.fullProps();
×
NEW
126
        context.getModel().getRelease().getReleaser().fillProps(props, context);
×
127
        return trusts.stream()
×
NEW
128
            .map(s -> resolveTemplate(context.getLogger(), s, props))
×
NEW
129
            .collect(toList());
×
130
    }
131

132
    public String getVersion() {
133
        return version;
×
134
    }
135

136
    public void setVersion(String version) {
137
        this.version = version;
×
138
    }
×
139

140
    public String getScript() {
141
        return script;
×
142
    }
143

144
    public void setScript(String script) {
145
        this.script = script;
×
146
    }
×
147

148
    public List<String> getArgs() {
149
        return args;
×
150
    }
151

152
    public void setArgs(List<String> args) {
153
        this.args.clear();
×
154
        this.args.addAll(args);
×
155
    }
×
156

157
    public List<String> getJbangArgs() {
158
        return jbangArgs;
×
159
    }
160

161
    public void setJbangArgs(List<String> jbangArgs) {
162
        this.jbangArgs.clear();
×
163
        this.jbangArgs.addAll(jbangArgs);
×
164
    }
×
165

166
    public List<String> getTrusts() {
167
        return trusts;
×
168
    }
169

170
    public void setTrusts(List<String> trusts) {
171
        this.trusts.clear();
×
172
        this.trusts.addAll(trusts);
×
173
    }
×
174

175
    @Override
176
    public Map<String, Object> asMap(boolean full) {
177
        Map<String, Object> props = new LinkedHashMap<>();
×
178
        props.put("version", version);
×
179
        props.put("script", script);
×
180
        props.put("args", args);
×
181
        props.put("jbangArgs", jbangArgs);
×
182
        props.put("trusts", trusts);
×
183
        return props;
×
184
    }
185
}
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