@@ -2,6 +2,7 @@ package org.javacs.kt.classpath
2
2
3
3
import org.javacs.kt.LOG
4
4
import org.javacs.kt.util.findCommandOnPath
5
+ import org.javacs.kt.util.execAndReadStdoutAndStderr
5
6
import java.nio.file.Path
6
7
import java.nio.file.Files
7
8
import java.io.File
@@ -60,20 +61,14 @@ private fun mavenJarName(a: Artifact, source: Boolean) =
60
61
61
62
private fun generateMavenDependencyList (pom : Path ): Path {
62
63
val mavenOutput = Files .createTempFile(" deps" , " .txt" )
63
- val workingDirectory = pom.toAbsolutePath().parent.toFile()
64
- val cmd = " $mvnCommand dependency:list -DincludeScope=test -DoutputFile=$mavenOutput "
65
- LOG .info(" Run {} in {}" , cmd, workingDirectory)
66
- val process = Runtime .getRuntime().exec(cmd, null , workingDirectory)
67
-
68
- process.inputStream.bufferedReader().use { reader ->
69
- while (process.isAlive) {
70
- val line = reader.readLine()?.trim() ? : break
71
- if (line.isNotEmpty() && ! line.startsWith(" Progress" )) {
72
- LOG .info(" Maven: {}" , line)
73
- }
74
- }
64
+ val command = " $mvnCommand dependency:list -DincludeScope=test -DoutputFile=$mavenOutput "
65
+ val workingDirectory = pom.toAbsolutePath().parent
66
+ LOG .info(" Run {} in {}" , command, workingDirectory)
67
+ val (result, errors) = execAndReadStdoutAndStderr(command, workingDirectory)
68
+ LOG .debug(result)
69
+ if (" BUILD FAILURE" in errors) {
70
+ LOG .warn(" Maven task failed: {}" , errors.lines().firstOrNull())
75
71
}
76
-
77
72
return mavenOutput
78
73
}
79
74
0 commit comments