@@ -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.findProjectCommandWithName
5
6
import org.javacs.kt.util.execAndReadStdoutAndStderr
6
7
import java.nio.file.Path
7
8
import java.nio.file.Files
@@ -103,14 +104,14 @@ private fun mavenJarName(a: Artifact, source: Boolean) =
103
104
104
105
private fun generateMavenDependencyList (pom : Path ): Path {
105
106
val mavenOutput = Files .createTempFile(" deps" , " .txt" )
106
- val command = " $mvnCommand dependency:list -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
107
+ val command = " ${ mvnCommand(pom)} dependency:list -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
107
108
runCommand(pom, command)
108
109
return mavenOutput
109
110
}
110
111
111
112
private fun generateMavenDependencySourcesList (pom : Path ): Path {
112
113
val mavenOutput = Files .createTempFile(" sources" , " .txt" )
113
- val command = " $mvnCommand dependency:sources -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
114
+ val command = " ${ mvnCommand(pom)} dependency:sources -DincludeScope=test -DoutputFile=$mavenOutput -Dstyle.color=never"
114
115
runCommand(pom, command)
115
116
return mavenOutput
116
117
}
@@ -125,8 +126,14 @@ private fun runCommand(pom: Path, command: String) {
125
126
}
126
127
}
127
128
128
- private val mvnCommand: Path by lazy {
129
- requireNotNull(findCommandOnPath(" mvn" )) { " Unable to find the 'mvn' command" }
129
+ private val mvnCommandFromPath: Path ? by lazy {
130
+ findCommandOnPath(" mvn" )
131
+ }
132
+
133
+ private fun mvnCommand (pom : Path ): Path {
134
+ return requireNotNull(mvnCommandFromPath ? : findProjectCommandWithName(" mvnw" , pom)?.also {
135
+ LOG .info(" Using mvn wrapper (mvnw) in place of mvn command" )
136
+ }) { " Unable to find the 'mvn' command or suitable wrapper" }
130
137
}
131
138
132
139
fun parseMavenArtifact (rawArtifact : String , version : String? = null): Artifact {
0 commit comments