@@ -71,7 +71,7 @@ object JlinkPlugin extends AutoPlugin {
71
71
72
72
// Jdeps has a few convenient options (like --print-module-deps), but those
73
73
// are not flexible enough - we need to parse the full output.
74
- val jdepsOutput = runForOutput( run(" jdeps" , " --multi-release" +: javaVersion +: " -R" +: paths), log )
74
+ val jdepsOutput = run(" jdeps" , " --multi-release" +: javaVersion +: " -R" +: paths)
75
75
76
76
val deps = jdepsOutput.linesIterator
77
77
// There are headers in some of the lines - ignore those.
@@ -146,7 +146,7 @@ object JlinkPlugin extends AutoPlugin {
146
146
147
147
IO .delete(outDir)
148
148
149
- runForOutput( run(" jlink" , jlinkOptions.value), log )
149
+ run(" jlink" , jlinkOptions.value)
150
150
151
151
outDir
152
152
},
@@ -176,12 +176,26 @@ object JlinkPlugin extends AutoPlugin {
176
176
private lazy val defaultJavaHome : File =
177
177
file(sys.props.getOrElse(" java.home" , sys.error(" no java.home" )))
178
178
179
- private def runJavaTool (jvm : File , log : Logger )(exeName : String , args : Seq [String ]): ProcessBuilder = {
180
- val exe = (jvm / " bin " / exeName).getAbsolutePath
179
+ private def runJavaTool (jvm : File , log : Logger )(toolName : String , args : Seq [String ]): String = {
180
+ log.info( " Running: " + (toolName +: args).mkString( " " ))
181
181
182
- log.info(" Running: " + (exe +: args).mkString(" " ))
182
+ val toolLauncherClass = classOf [ru.eldis.toollauncher.ToolLauncher ]
183
+ val toolLauncherJar = file(
184
+ // This assumes that the code source is a file or a directory (as opposed
185
+ // to a remote URL) - but that should hold.
186
+ toolLauncherClass.getProtectionDomain.getCodeSource.getLocation.getPath
187
+ ).getAbsolutePath
183
188
184
- Process (exe, args)
189
+ val javaExe = (jvm / " bin" / " java" ).getAbsolutePath
190
+
191
+ IO .withTemporaryFile(s " snp- $toolName- " , " args" ) { argFile =>
192
+ IO .writeLines(argFile, args)
193
+
194
+ val argFileArg = " @" + argFile.getAbsolutePath
195
+ val builder = Process (Vector (javaExe, " -jar" , toolLauncherJar, " -tool" , toolName, argFileArg))
196
+
197
+ runForOutput(builder, log)
198
+ }
185
199
}
186
200
187
201
// Like `ProcessBuilder.!!`, but this logs the output in case of a non-zero
0 commit comments