diff options
-rw-r--r-- | src/main/java/org/javacs/InferConfig.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/org/javacs/InferConfig.java b/src/main/java/org/javacs/InferConfig.java index f6c5dea..8568ffb 100644 --- a/src/main/java/org/javacs/InferConfig.java +++ b/src/main/java/org/javacs/InferConfig.java @@ -289,13 +289,27 @@ class InferConfig { var outputFile = Files.createTempFile("deps", ".txt"); // TODO consider using mvn dependency:copy-dependencies instead - var cmd = - String.format( - "%s dependency:list -DincludeScope=test -DoutputFile=%s", getMvnCommand(), outputFile); + var command = + List.of( + getMvnCommand(), + "validate", + "dependency:list", + "-DincludeScope=test", + "-DoutputFile=" + outputFile); + LOG.info("Running " + String.join(" ", command) + " ..."); var workingDirectory = pomXml.toAbsolutePath().getParent().toFile(); - var result = Runtime.getRuntime().exec(cmd, null, workingDirectory).waitFor(); - - if (result != 0) throw new RuntimeException("`" + cmd + "` returned " + result); + var log = Files.createTempFile("maven", ".log"); + LOG.info("...sending output to " + log); + var result = + new ProcessBuilder() + .command(command) + .directory(workingDirectory) + .redirectError(ProcessBuilder.Redirect.INHERIT) + .redirectOutput(ProcessBuilder.Redirect.to(log.toFile())) + .start() + .waitFor(); + + if (result != 0) throw new RuntimeException("`" + String.join(" ", command) + "` returned " + result); return readDependencyList(outputFile); } catch (InterruptedException | IOException e) { |