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

jreleaser / jreleaser / #537

25 Sep 2025 02:50PM UTC coverage: 48.299% (-0.7%) from 48.959%
#537

push

github

web-flow
fix: check snapshot version for '-SNAPSHOT' tag

Fixe #1971

2 of 2 new or added lines in 1 file covered. (100.0%)

362 existing lines in 31 files now uncovered.

25821 of 53461 relevant lines covered (48.3%)

0.48 hits per line

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

68.18
/sdks/jreleaser-command-java-sdk/src/main/java/org/jreleaser/sdk/command/Command.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.sdk.command;
19

20
import org.jreleaser.util.PlatformUtils;
21

22
import java.io.File;
23
import java.io.IOException;
24
import java.nio.file.Files;
25
import java.util.ArrayList;
26
import java.util.Collection;
27
import java.util.Collections;
28
import java.util.List;
29

30
/**
31
 * @author Andres Almiray
32
 * @since 0.8.0
33
 */
34
@org.jreleaser.infra.nativeimage.annotations.NativeImage
35
public class Command {
36
    private final List<String> args = new ArrayList<>();
1✔
37
    private final boolean supportsArgsfile;
38

39
    public Command() {
×
40
        this.supportsArgsfile = false;
×
41
    }
×
42

43
    public Command(String arg) {
1✔
44
        this.supportsArgsfile = false;
1✔
45
        this.args.add(arg);
1✔
46
    }
1✔
47

48
    public Command(String arg, boolean supportsArgsfile) {
1✔
49
        this.supportsArgsfile = supportsArgsfile;
1✔
50
        this.args.add(arg);
1✔
51
    }
1✔
52

53
    public Command(List<String> args) {
1✔
54
        this.supportsArgsfile = false;
1✔
55
        this.args.addAll(args);
1✔
56
    }
1✔
57

58
    public boolean isSupportsArgsfile() {
59
        return supportsArgsfile;
×
60
    }
61

62
    public List<String> getArgs() {
63
        return Collections.unmodifiableList(args);
1✔
64
    }
65

66
    public boolean hasArg(String arg) {
UNCOV
67
        return args.contains(arg);
×
68
    }
69

70
    public Command arg(String arg) {
71
        this.args.add(arg);
1✔
72
        return this;
1✔
73
    }
74

75
    public Command args(Collection<String> args) {
76
        this.args.addAll(args);
1✔
77
        return this;
1✔
78
    }
79

80
    public List<String> asCommandLine() throws IOException {
81
        if (!supportsArgsfile) return getArgs();
1✔
82

83
        if (PlatformUtils.isWindows()) {
1✔
84
            File argsFile = File.createTempFile("jreleaser-command", "args");
×
85
            argsFile.deleteOnExit();
×
86
            Files.write(argsFile.toPath(), (Iterable<String>) args.stream().skip(1)::iterator);
×
87

88
            String cmd = args.get(0);
×
89
            args.clear();
×
90
            args.add(cmd);
×
91
            args.add("@" + argsFile);
×
92
        }
93

94
        return getArgs();
1✔
95
    }
96

97
    public static class Result {
98
        private final String out;
99
        private final String err;
100
        private final int exitValue;
101

102
        public static Result empty() {
103
            return new Result("", "", -1);
1✔
104
        }
105

106
        public static Result of(String err, int exitValue) {
107
            return new Result("", err, exitValue);
×
108
        }
109

110
        public static Result of(String out, String err, int exitValue) {
111
            return new Result(out, err, exitValue);
1✔
112
        }
113

114
        private Result(String out, String err, int exitValue) {
1✔
115
            this.out = out.trim();
1✔
116
            this.err = err.trim();
1✔
117
            this.exitValue = exitValue;
1✔
118
        }
1✔
119

120
        public String getOut() {
121
            return out;
1✔
122
        }
123

124
        public String getErr() {
UNCOV
125
            return err;
×
126
        }
127

128
        public int getExitValue() {
129
            return exitValue;
1✔
130
        }
131
    }
132
}
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