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

jreleaser / jreleaser / #556

22 Nov 2025 04:17PM UTC coverage: 46.213% (-2.0%) from 48.203%
#556

push

github

aalmiray
feat(jdks): Allow filtering by platform

Closes #2000

Co-authored-by: Ixchel Ruiz <ixchelruiz@yahoo.com>

0 of 42 new or added lines in 5 files covered. (0.0%)

1116 existing lines in 107 files now uncovered.

24939 of 53965 relevant lines covered (46.21%)

0.46 hits per line

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

0.87
/plugins/jreleaser/src/main/java/org/jreleaser/cli/Release.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.cli;
19

20
import org.jreleaser.engine.context.ModelAutoConfigurer;
21
import org.jreleaser.model.UpdateSection;
22
import org.jreleaser.model.api.JReleaserCommand;
23
import org.jreleaser.model.internal.JReleaserContext;
24
import org.jreleaser.workflow.Workflows;
25
import picocli.CommandLine;
26

27
import java.nio.file.Files;
28
import java.nio.file.Paths;
29
import java.util.LinkedHashSet;
30
import java.util.Set;
31

32
/**
33
 * @author Andres Almiray
34
 * @since 0.1.0
35
 */
36
@CommandLine.Command(name = "release")
37
public class Release extends AbstractPlatformAwareModelCommand<Main> {
1✔
38
    @CommandLine.Option(names = {"--dry-run"})
39
    Boolean dryrun;
40

41
    @CommandLine.ArgGroup
42
    Composite composite;
43

UNCOV
44
    static class Composite {
×
45
        @CommandLine.ArgGroup(exclusive = false, order = 1,
46
            headingKey = "include.filter.header")
47
        Include include;
48

49
        @CommandLine.ArgGroup(exclusive = false, order = 2,
50
            headingKey = "exclude.filter.header")
51
        Exclude exclude;
52

53
        @CommandLine.ArgGroup(exclusive = false, order = 3,
54
            headingKey = "auto-config.header")
55
        AutoConfigGroup autoConfig;
56

57
        String[] includedDistributions() {
58
            return null != include ? include.includedDistributions : null;
×
59
        }
60

61
        String[] excludedDistributions() {
62
            return null != exclude ? exclude.excludedDistributions : null;
×
63
        }
64

65
        String[] includedDeployerTypes() {
66
            return null != include ? include.includedDeployerTypes : null;
×
67
        }
68

69
        String[] includedDeployerNames() {
70
            return null != include ? include.includedDeployerNames : null;
×
71
        }
72

73
        String[] excludedDeployerTypes() {
74
            return null != exclude ? exclude.excludedDeployerTypes : null;
×
75
        }
76

77
        String[] excludedDeployerNames() {
78
            return null != exclude ? exclude.excludedDeployerNames : null;
×
79
        }
80

81
        String[] includedUploaderTypes() {
82
            return null != include ? include.includedUploaderTypes : null;
×
83
        }
84

85
        String[] includedUploaderNames() {
86
            return null != include ? include.includedUploaderNames : null;
×
87
        }
88

89
        String[] excludedUploaderTypes() {
90
            return null != exclude ? exclude.excludedUploaderTypes : null;
×
91
        }
92

93
        String[] excludedUploaderNames() {
94
            return null != exclude ? exclude.excludedUploaderNames : null;
×
95
        }
96

97
        String[] includedCatalogers() {
98
            return null != include ? include.includedCatalogers : null;
×
99
        }
100

101
        String[] excludedCatalogers() {
102
            return null != exclude ? exclude.excludedCatalogers : null;
×
103
        }
104

105
        boolean isAutoConfig() {
UNCOV
106
            return null != autoConfig && autoConfig.autoConfig;
×
107
        }
108
    }
109

110
    static class Include {
×
111
        @CommandLine.Option(names = {"-d", "--distribution"},
112
            paramLabel = "<distribution>")
113
        String[] includedDistributions;
114

115
        @CommandLine.Option(names = {"-y", "--deployer"},
116
            paramLabel = "<deployer>")
117
        String[] includedDeployerTypes;
118

119
        @CommandLine.Option(names = {"-yn", "--deployer-name"},
120
            paramLabel = "<name>")
121
        String[] includedDeployerNames;
122

123
        @CommandLine.Option(names = {"-u", "--uploader"},
124
            paramLabel = "<uploader>")
125
        String[] includedUploaderTypes;
126

127
        @CommandLine.Option(names = {"-un", "--uploader-name"},
128
            paramLabel = "<name>")
129
        String[] includedUploaderNames;
130

131
        @CommandLine.Option(names = {"--cataloger"},
132
            paramLabel = "<cataloger>")
133
        String[] includedCatalogers;
134
    }
135

136
    static class Exclude {
×
137
        @CommandLine.Option(names = {"-xd", "--exclude-distribution"},
138
            paramLabel = "<distribution>")
139
        String[] excludedDistributions;
140

141
        @CommandLine.Option(names = {"-xy", "--exclude-deployer"},
142
            paramLabel = "<deployer>")
143
        String[] excludedDeployerTypes;
144

145
        @CommandLine.Option(names = {"-xyn", "--exclude-deployer-name"},
146
            paramLabel = "<name>")
147
        String[] excludedDeployerNames;
148

149
        @CommandLine.Option(names = {"-xu", "--exclude-uploader"},
150
            paramLabel = "<uploader>")
151
        String[] excludedUploaderTypes;
152

153
        @CommandLine.Option(names = {"-xun", "--exclude-uploader-name"},
154
            paramLabel = "<name>")
155
        String[] excludedUploaderNames;
156

157
        @CommandLine.Option(names = {"--exclude-cataloger"},
158
            paramLabel = "<cataloger>")
159
        String[] excludedCatalogers;
160
    }
161

UNCOV
162
    static class AutoConfigGroup {
×
163
        @CommandLine.Option(names = {"--auto-config"})
164
        boolean autoConfig;
165

166
        @CommandLine.Option(names = {"--project-name"}, paramLabel = "<name>")
167
        String projectName;
168

169
        @CommandLine.Option(names = {"--project-version"}, paramLabel = "<version>")
170
        String projectVersion;
171

172
        @CommandLine.Option(names = {"--project-version-pattern"}, paramLabel = "<pattern>")
173
        String projectVersionPattern;
174

175
        @CommandLine.Option(names = {"--project-snapshot-pattern"}, paramLabel = "<pattern>")
176
        String projectSnapshotPattern;
177

178
        @CommandLine.Option(names = {"--project-snapshot-label"}, paramLabel = "<label>")
179
        String projectSnapshotLabel;
180

181
        @CommandLine.Option(names = {"--project-snapshot-full-changelog"})
182
        boolean projectSnapshotFullChangelog;
183

184
        @CommandLine.Option(names = {"--project-copyright"}, paramLabel = "<copyright>")
185
        String projectCopyright;
186

187
        @CommandLine.Option(names = {"--project-description"}, paramLabel = "<description>")
188
        String projectDescription;
189

190
        @CommandLine.Option(names = {"--project-inception-year"}, paramLabel = "<year>")
191
        String projectInceptionYear;
192

193
        @CommandLine.Option(names = {"--project-stereotype"}, paramLabel = "<stereotype>")
194
        String projectStereotype;
195

196
        @CommandLine.Option(names = {"--author"},
197
                paramLabel = "<author>")
198
        String[] authors;
199

200
        @CommandLine.Option(names = {"--tag-name"}, paramLabel = "<tag>")
201
        String tagName;
202

203
        @CommandLine.Option(names = {"--previous-tag-name"}, paramLabel = "<tag>")
204
        String previousTagName;
205

206
        @CommandLine.Option(names = {"--release-name"}, paramLabel = "<name>")
207
        String releaseName;
208

209
        @CommandLine.Option(names = {"--milestone-name"}, paramLabel = "<name>")
210
        String milestoneName;
211

212
        @CommandLine.Option(names = {"--prerelease"})
213
        Boolean prerelease;
214

215
        @CommandLine.Option(names = {"--prerelease-pattern"}, paramLabel = "<pattern>")
216
        String prereleasePattern;
217

218
        @CommandLine.Option(names = {"--draft"})
219
        Boolean draft;
220

221
        @CommandLine.Option(names = {"--overwrite"})
222
        boolean overwrite;
223

224
        @CommandLine.Option(names = {"--update"})
225
        boolean update;
226

227
        @CommandLine.Option(names = {"--update-section"},
228
            paramLabel = "<section>")
229
        String[] updateSections;
230

231
        @CommandLine.Option(names = {"--skip-tag"})
232
        boolean skipTag;
233

234
        @CommandLine.Option(names = {"--skip-release"})
235
        boolean skipRelease;
236

237
        @CommandLine.Option(names = {"--skip-checksums"})
238
        boolean skipChecksums;
239

240
        @CommandLine.Option(names = {"--branch"})
241
        String branch;
242

243
        @CommandLine.Option(names = {"--changelog"})
244
        String changelog;
245

246
        @CommandLine.Option(names = {"--changelog-formatted"})
247
        boolean changelogFormatted;
248

249
        @CommandLine.Option(names = {"--username"})
250
        String username;
251

252
        @CommandLine.Option(names = {"--commit-author-name"}, paramLabel = "<name>")
253
        String commitAuthorName;
254

255
        @CommandLine.Option(names = {"--commit-author-email"}, paramLabel = "<email>")
256
        String commitAuthorEmail;
257

258
        @CommandLine.Option(names = {"--signing-enabled"})
259
        boolean signing;
260

261
        @CommandLine.Option(names = {"--signing-armored"})
262
        boolean armored;
263

264
        @CommandLine.Option(names = {"--file"},
265
            paramLabel = "<file>")
266
        String[] files;
267

268
        @CommandLine.Option(names = {"--glob"},
269
            paramLabel = "<glob>")
270
        String[] globs;
271
    }
272

273
    @Override
274
    protected void collectCandidateDeprecatedArgs(Set<AbstractCommand.DeprecatedArg> args) {
UNCOV
275
        super.collectCandidateDeprecatedArgs(args);
×
UNCOV
276
        args.add(new DeprecatedArg("-d", "--distribution", "1.5.0"));
×
UNCOV
277
        args.add(new DeprecatedArg("-xd", "--exclude-distribution", "1.5.0"));
×
UNCOV
278
        args.add(new DeprecatedArg("-y", "--deployer", "1.5.0"));
×
UNCOV
279
        args.add(new DeprecatedArg("-yn", "--deployer-name", "1.5.0"));
×
UNCOV
280
        args.add(new DeprecatedArg("-xy", "--exclude-deployer", "1.5.0"));
×
UNCOV
281
        args.add(new DeprecatedArg("-xyn", "--exclude-deployer-name", "1.5.0"));
×
UNCOV
282
        args.add(new DeprecatedArg("-u", "--uploader", "1.5.0"));
×
UNCOV
283
        args.add(new DeprecatedArg("-un", "--uploader-name", "1.5.0"));
×
UNCOV
284
        args.add(new DeprecatedArg("-xu", "--exclude-uploader", "1.5.0"));
×
UNCOV
285
        args.add(new DeprecatedArg("-xun", "--exclude-uploader-name", "1.5.0"));
×
UNCOV
286
    }
×
287

288
    @Override
289
    protected JReleaserContext createContext() {
UNCOV
290
        JReleaserContext context = super.createContext();
×
UNCOV
291
        if (null != composite) {
×
292
            context.setIncludedDistributions(collectEntries(composite.includedDistributions()));
×
293
            context.setIncludedDeployerTypes(collectEntries(composite.includedDeployerTypes(), true));
×
294
            context.setIncludedDeployerNames(collectEntries(composite.includedDeployerNames()));
×
295
            context.setIncludedUploaderTypes(collectEntries(composite.includedUploaderTypes(), true));
×
296
            context.setIncludedUploaderNames(collectEntries(composite.includedUploaderNames()));
×
297
            context.setIncludedCatalogers(collectEntries(composite.includedCatalogers(), true));
×
298
            context.setExcludedDistributions(collectEntries(composite.excludedDistributions()));
×
299
            context.setExcludedDeployerTypes(collectEntries(composite.excludedDeployerTypes(), true));
×
300
            context.setExcludedDeployerNames(collectEntries(composite.excludedDeployerNames()));
×
301
            context.setExcludedUploaderTypes(collectEntries(composite.excludedUploaderTypes(), true));
×
302
            context.setExcludedUploaderNames(collectEntries(composite.excludedUploaderNames()));
×
303
            context.setExcludedCatalogers(collectEntries(composite.excludedCatalogers(), true));
×
304
        }
UNCOV
305
        return context;
×
306
    }
307

308
    @Override
309
    protected void execute() {
UNCOV
310
        if (null == composite || !composite.isAutoConfig()) {
×
UNCOV
311
            super.execute();
×
UNCOV
312
            return;
×
313
        }
314

UNCOV
315
        basedir();
×
UNCOV
316
        initLogger();
×
317

UNCOV
318
        JReleaserContext context = ModelAutoConfigurer.builder()
×
UNCOV
319
            .logger(logger)
×
UNCOV
320
            .basedir(actualBasedir)
×
UNCOV
321
            .settings(settingsFile)
×
UNCOV
322
            .outputDirectory(getOutputDirectory())
×
UNCOV
323
            .yolo(yolo())
×
UNCOV
324
            .dryrun(dryrun())
×
UNCOV
325
            .gitRootSearch(gitRootSearch())
×
UNCOV
326
            .strict(strict())
×
UNCOV
327
            .projectName(composite.autoConfig.projectName)
×
UNCOV
328
            .projectVersion(composite.autoConfig.projectVersion)
×
UNCOV
329
            .projectVersionPattern(composite.autoConfig.projectVersionPattern)
×
UNCOV
330
            .projectSnapshotPattern(composite.autoConfig.projectSnapshotPattern)
×
UNCOV
331
            .projectSnapshotLabel(composite.autoConfig.projectSnapshotLabel)
×
UNCOV
332
            .projectSnapshotFullChangelog(composite.autoConfig.projectSnapshotFullChangelog)
×
UNCOV
333
            .projectCopyright(composite.autoConfig.projectCopyright)
×
UNCOV
334
            .projectDescription(composite.autoConfig.projectDescription)
×
UNCOV
335
            .projectInceptionYear(composite.autoConfig.projectInceptionYear)
×
UNCOV
336
            .projectStereotype(composite.autoConfig.projectStereotype)
×
UNCOV
337
            .authors(collectEntries(composite.autoConfig.authors))
×
UNCOV
338
            .tagName(composite.autoConfig.tagName)
×
UNCOV
339
            .previousTagName(composite.autoConfig.previousTagName)
×
UNCOV
340
            .releaseName(composite.autoConfig.releaseName)
×
UNCOV
341
            .milestoneName(composite.autoConfig.milestoneName)
×
UNCOV
342
            .branch(composite.autoConfig.branch)
×
UNCOV
343
            .prerelease(composite.autoConfig.prerelease)
×
UNCOV
344
            .prereleasePattern(composite.autoConfig.prereleasePattern)
×
UNCOV
345
            .draft(composite.autoConfig.draft)
×
UNCOV
346
            .overwrite(composite.autoConfig.overwrite)
×
UNCOV
347
            .update(composite.autoConfig.update)
×
UNCOV
348
            .updateSections(collectUpdateSections())
×
UNCOV
349
            .skipTag(composite.autoConfig.skipTag)
×
UNCOV
350
            .skipRelease(composite.autoConfig.skipRelease)
×
UNCOV
351
            .skipChecksums(composite.autoConfig.skipChecksums)
×
UNCOV
352
            .changelog(composite.autoConfig.changelog)
×
UNCOV
353
            .changelogFormatted(composite.autoConfig.changelogFormatted)
×
UNCOV
354
            .username(composite.autoConfig.username)
×
UNCOV
355
            .commitAuthorName(composite.autoConfig.commitAuthorName)
×
UNCOV
356
            .commitAuthorEmail(composite.autoConfig.commitAuthorEmail)
×
UNCOV
357
            .signing(composite.autoConfig.signing)
×
UNCOV
358
            .armored(composite.autoConfig.armored)
×
UNCOV
359
            .files(collectEntries(composite.autoConfig.files))
×
UNCOV
360
            .globs(collectEntries(composite.autoConfig.globs))
×
UNCOV
361
            .selectedPlatforms(collectSelectedPlatforms())
×
UNCOV
362
            .rejectedPlatforms(collectRejectedPlatforms())
×
UNCOV
363
            .autoConfigure();
×
364

UNCOV
365
        doExecute(context);
×
UNCOV
366
    }
×
367

368
    private Set<UpdateSection> collectUpdateSections() {
UNCOV
369
        Set<UpdateSection> set = new LinkedHashSet<>();
×
UNCOV
370
        if (null != composite.autoConfig.updateSections && composite.autoConfig.updateSections.length > 0) {
×
371
            for (String updateSection : composite.autoConfig.updateSections) {
×
372
                set.add(UpdateSection.of(updateSection.trim()));
×
373
            }
374
        }
UNCOV
375
        return set;
×
376
    }
377

378
    private void basedir() {
UNCOV
379
        actualBasedir = null != basedir ? basedir : Paths.get(".").normalize();
×
UNCOV
380
        if (!Files.exists(actualBasedir)) {
×
381
            throw halt($("ERROR_missing_required_option", "--basedir=<basedir>"));
×
382
        }
UNCOV
383
    }
×
384

385
    @Override
386
    protected void doExecute(JReleaserContext context) {
UNCOV
387
        Workflows.release(context).execute();
×
UNCOV
388
    }
×
389

390
    @Override
391
    protected Boolean dryrun() {
UNCOV
392
        return dryrun;
×
393
    }
394

395
    private HaltExecutionException halt(String message) throws HaltExecutionException {
396
        spec.commandLine().getErr()
×
397
            .println(spec.commandLine().getColorScheme().errorText(message));
×
398
        spec.commandLine().usage(parent().getOut());
×
399
        throw new HaltExecutionException();
×
400
    }
401

402
    @Override
403
    protected JReleaserCommand getCommand() {
UNCOV
404
        return JReleaserCommand.RELEASE;
×
405
    }
406
}
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