• 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

42.86
/plugins/jreleaser/src/main/java/org/jreleaser/cli/AbstractLoggingCommand.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.cli.internal.ColorizedJReleaserLoggerAdapter;
21
import org.jreleaser.logging.JReleaserLogger;
22
import org.jreleaser.util.StringUtils;
23
import picocli.CommandLine;
24

25
import java.io.FileOutputStream;
26
import java.io.IOException;
27
import java.io.PrintWriter;
28
import java.nio.file.Files;
29
import java.nio.file.Path;
30
import java.util.ArrayList;
31
import java.util.List;
32
import java.util.Locale;
33
import java.util.Set;
34
import java.util.concurrent.Callable;
35

36
import static org.jreleaser.model.JReleaserOutput.JRELEASER_QUIET;
37
import static org.jreleaser.util.IoUtils.newPrintWriter;
38
import static org.jreleaser.util.StringUtils.isNotBlank;
39

40
/**
41
 * @author Andres Almiray
42
 * @since 0.1.0
43
 */
44
public abstract class AbstractLoggingCommand<C extends IO> extends AbstractCommand<C> implements Callable<Integer> {
1✔
45
    protected JReleaserLogger logger;
46

47
    @CommandLine.Option(names = {"-g", "--debug"})
48
    boolean debug;
49

50
    @CommandLine.Option(names = {"-i", "--info"})
51
    boolean info;
52

53
    @CommandLine.Option(names = {"-w", "--warn"})
54
    boolean warn;
55

56
    @CommandLine.Option(names = {"-q", "--quiet"})
57
    boolean quiet;
58

59
    @CommandLine.Option(names = {"-b", "--basedir"}, paramLabel = "<directory>")
60
    Path basedir;
61

62
    @CommandLine.Option(names = {"-od", "--output-directory"}, paramLabel = "<directory>")
63
    Path outputdir;
64

65
    protected ColorizedJReleaserLoggerAdapter.Level level = ColorizedJReleaserLoggerAdapter.Level.INFO;
1✔
66

67
    @Override
68
    protected void setup() {
69
        if (debug) {
1✔
70
            level = ColorizedJReleaserLoggerAdapter.Level.DEBUG;
×
71
            System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "debug");
×
72
        } else if (info) {
1✔
73
            level = ColorizedJReleaserLoggerAdapter.Level.INFO;
×
74
            System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "info");
×
75
        } else if (warn) {
1✔
76
            level = ColorizedJReleaserLoggerAdapter.Level.WARN;
×
77
            System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "warn");
×
78
        } else if (quiet) {
1✔
79
            level = ColorizedJReleaserLoggerAdapter.Level.ERROR;
×
80
            System.setProperty("org.slf4j.simpleLogger.org.jreleaser", "error");
×
81
            System.setProperty(JRELEASER_QUIET, "true");
×
82
        }
83

84
        Banner.display(parent().getErr());
1✔
85
    }
1✔
86

87
    @Override
88
    protected void collectCandidateDeprecatedArgs(Set<AbstractCommand.DeprecatedArg> args) {
89
        args.add(new DeprecatedArg("-od", "--output-directory", "1.5.0"));
1✔
90
    }
1✔
91

92
    protected void initLogger() {
93
        logger = new ColorizedJReleaserLoggerAdapter(createTracer(), parent().getOut(), level);
1✔
94
    }
1✔
95

96
    protected PrintWriter createTracer() {
97
        try {
98
            Files.createDirectories(getOutputDirectory());
1✔
99
            return newPrintWriter(new FileOutputStream(
1✔
100
                    getOutputDirectory().resolve("trace.log").toFile()));
1✔
101
        } catch (IOException e) {
×
102
            throw new IllegalStateException($("ERROR_trace_file_init"), e);
×
103
        }
104
    }
105

106
    protected abstract Path getOutputDirectory();
107

108
    protected List<String> collectEntries(String[] input) {
UNCOV
109
        return collectEntries(input, false);
×
110
    }
111

112
    protected List<String> collectEntries(String[] input, boolean lowerCase) {
UNCOV
113
        List<String> list = new ArrayList<>();
×
UNCOV
114
        if (null != input && input.length > 0) {
×
UNCOV
115
            for (String s : input) {
×
UNCOV
116
                if (isNotBlank(s)) {
×
UNCOV
117
                    if (!s.contains("-") && lowerCase) {
×
UNCOV
118
                        s = StringUtils.getHyphenatedName(s);
×
119
                    }
UNCOV
120
                    list.add(lowerCase ? s.toLowerCase(Locale.ENGLISH) : s);
×
121
                }
122
            }
123
        }
UNCOV
124
        return list;
×
125
    }
126
}
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