Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/main/java/com/redhat/exhort/providers/JavaMavenProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class JavaMavenProvider extends BaseJavaProvider {
private static final String PROP_JAVA_HOME = "JAVA_HOME";
private static final Logger log = LoggersFactory.getLogger(JavaMavenProvider.class.getName());
private final String mvnExecutable;
private static final String MVN = "mvn";
private static final String MVN = Operations.isWindows() ? "mvn.cmd" : "mvn";
private static final String ARG_VERSION = "-v";

public JavaMavenProvider(Path manifest) {
Expand All @@ -65,7 +65,8 @@ public JavaMavenProvider(Path manifest) {

@Override
public Content provideStack() throws IOException {
var mvnCleanCmd = new String[] {mvnExecutable, "clean", "-f", manifest.toString()};
var mvnCleanCmd =
new String[] {mvnExecutable, "clean", "-f", manifest.toString(), "--batch-mode", "-q"};
var mvnEnvs = getMvnExecEnvs();
// execute the clean command
Operations.runProcess(manifest.getParent(), mvnCleanCmd, mvnEnvs);
Expand All @@ -82,6 +83,8 @@ public Content provideStack() throws IOException {
add(String.format("-DoutputFile=%s", tmpFile.toString()));
add("-f");
add(manifest.toString());
add("--batch-mode");
add("-q");
}
};
// if we have dependencies marked as ignored, exclude them from the tree command
Expand Down Expand Up @@ -136,7 +139,9 @@ private Content generateSbomFromEffectivePom() throws IOException {
"help:effective-pom",
String.format("-Doutput=%s", tmpEffPom.toString()),
"-f",
manifest.toString()
manifest.toString(),
"--batch-mode",
"-q"
};
// execute the effective pom command
Operations.runProcess(manifest.getParent(), mvnEffPomCmd, getMvnExecEnvs());
Expand Down Expand Up @@ -372,13 +377,13 @@ public int hashCode() {
private String selectMvnRuntime(final Path manifestPath) {
boolean preferWrapper = Operations.getWrapperPreference(MVN);
if (preferWrapper) {
String wrapperName = isWindows() ? "mvnw.cmd" : "mvnw";
String wrapperName = Operations.isWindows() ? "mvnw.cmd" : "mvnw";
String mvnw = traverseForMvnw(wrapperName, manifestPath.toString());
if (mvnw != null) {
try {
// verify maven wrapper is accessible
Operations.runProcess(manifest.getParent(), mvnw, ARG_VERSION);
log.fine("using maven wrapper from : " + mvnw);
log.fine(String.format("using maven wrapper from : %s", mvnw));
return mvnw;
} catch (Exception e) {
log.warning(
Expand All @@ -388,7 +393,7 @@ private String selectMvnRuntime(final Path manifestPath) {
}
// If maven wrapper is not requested or not accessible, fall back to use mvn
String mvn = Operations.getExecutable(MVN, ARG_VERSION);
log.fine("using mvn executable from : " + mvn);
log.fine(String.format("using mvn executable from : %s", mvn));
return mvn;
}

Expand Down Expand Up @@ -423,13 +428,9 @@ public static String traverseForMvnw(
public static String normalizePath(String thePath) {
Path normalized = Paths.get(thePath).toAbsolutePath().normalize();
String result = normalized.toString();
if (isWindows()) {
if (Operations.isWindows()) {
result = result.toLowerCase();
}
return result;
}

private static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("win");
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/redhat/exhort/tools/Operations.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,8 @@ public static Optional<String> getGitRootDir(String cwd) {
}
return Optional.empty();
}

public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("win");
}
}
Loading