Skip to content

Commit 5f0a68c

Browse files
committed
fix: mvn binary in windows
Signed-off-by: Ruben Romero Montes <rromerom@redhat.com>
1 parent 0dd94ad commit 5f0a68c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/main/java/com/redhat/exhort/providers/JavaMavenProvider.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final class JavaMavenProvider extends BaseJavaProvider {
5454
private static final String PROP_JAVA_HOME = "JAVA_HOME";
5555
private static final Logger log = LoggersFactory.getLogger(JavaMavenProvider.class.getName());
5656
private final String mvnExecutable;
57-
private static final String MVN = "mvn";
57+
private static final String MVN = Operations.isWindows() ? "mvn.cmd" : "mvn";
5858
private static final String ARG_VERSION = "-v";
5959

6060
public JavaMavenProvider(Path manifest) {
@@ -65,7 +65,8 @@ public JavaMavenProvider(Path manifest) {
6565

6666
@Override
6767
public Content provideStack() throws IOException {
68-
var mvnCleanCmd = new String[] {mvnExecutable, "clean", "-f", manifest.toString()};
68+
var mvnCleanCmd =
69+
new String[] {mvnExecutable, "clean", "-f", manifest.toString(), "--batch-mode", "-q"};
6970
var mvnEnvs = getMvnExecEnvs();
7071
// execute the clean command
7172
Operations.runProcess(manifest.getParent(), mvnCleanCmd, mvnEnvs);
@@ -82,6 +83,8 @@ public Content provideStack() throws IOException {
8283
add(String.format("-DoutputFile=%s", tmpFile.toString()));
8384
add("-f");
8485
add(manifest.toString());
86+
add("--batch-mode");
87+
add("-q");
8588
}
8689
};
8790
// if we have dependencies marked as ignored, exclude them from the tree command
@@ -136,7 +139,9 @@ private Content generateSbomFromEffectivePom() throws IOException {
136139
"help:effective-pom",
137140
String.format("-Doutput=%s", tmpEffPom.toString()),
138141
"-f",
139-
manifest.toString()
142+
manifest.toString(),
143+
"--batch-mode",
144+
"-q"
140145
};
141146
// execute the effective pom command
142147
Operations.runProcess(manifest.getParent(), mvnEffPomCmd, getMvnExecEnvs());
@@ -378,7 +383,7 @@ private String selectMvnRuntime(final Path manifestPath) {
378383
try {
379384
// verify maven wrapper is accessible
380385
Operations.runProcess(manifest.getParent(), mvnw, ARG_VERSION);
381-
log.fine("using maven wrapper from : " + mvnw);
386+
log.fine(String.format("using maven wrapper from : %s", mvnw));
382387
return mvnw;
383388
} catch (Exception e) {
384389
log.warning(
@@ -388,7 +393,7 @@ private String selectMvnRuntime(final Path manifestPath) {
388393
}
389394
// If maven wrapper is not requested or not accessible, fall back to use mvn
390395
String mvn = Operations.getExecutable(MVN, ARG_VERSION);
391-
log.fine("using mvn executable from : " + mvn);
396+
log.fine(String.format("using mvn executable from : %s", mvn));
392397
return mvn;
393398
}
394399

0 commit comments

Comments
 (0)