-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JlinkPlugin: add support for huge classpaths #1270
Changes from all commits
b7a7734
d2a2cdc
fc1e800
2b6a9bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ object JlinkPlugin extends AutoPlugin { | |
|
||
// Jdeps has a few convenient options (like --print-module-deps), but those | ||
// are not flexible enough - we need to parse the full output. | ||
val jdepsOutput = runForOutput(run("jdeps", "--multi-release" +: javaVersion +: "-R" +: paths), log) | ||
val jdepsOutput = run("jdeps", "--multi-release" +: javaVersion +: "-R" +: paths) | ||
|
||
val deps = jdepsOutput.linesIterator | ||
// There are headers in some of the lines - ignore those. | ||
|
@@ -146,7 +146,7 @@ object JlinkPlugin extends AutoPlugin { | |
|
||
IO.delete(outDir) | ||
|
||
runForOutput(run("jlink", jlinkOptions.value), log) | ||
run("jlink", jlinkOptions.value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the sbt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that is a convenience helper for That idea can be revisited once we drop SBT 0.13. |
||
|
||
outDir | ||
}, | ||
|
@@ -176,12 +176,26 @@ object JlinkPlugin extends AutoPlugin { | |
private lazy val defaultJavaHome: File = | ||
file(sys.props.getOrElse("java.home", sys.error("no java.home"))) | ||
|
||
private def runJavaTool(jvm: File, log: Logger)(exeName: String, args: Seq[String]): ProcessBuilder = { | ||
val exe = (jvm / "bin" / exeName).getAbsolutePath | ||
private def runJavaTool(jvm: File, log: Logger)(toolName: String, args: Seq[String]): String = { | ||
log.info("Running: " + (toolName +: args).mkString(" ")) | ||
|
||
log.info("Running: " + (exe +: args).mkString(" ")) | ||
val toolLauncherClass = classOf[ru.eldis.toollauncher.ToolLauncher] | ||
val toolLauncherJar = file( | ||
// This assumes that the code source is a file or a directory (as opposed | ||
// to a remote URL) - but that should hold. | ||
toolLauncherClass.getProtectionDomain.getCodeSource.getLocation.getPath | ||
).getAbsolutePath | ||
Comment on lines
+182
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just if I got this right: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is correct. We could resolve the JAR separately (via |
||
|
||
Process(exe, args) | ||
val javaExe = (jvm / "bin" / "java").getAbsolutePath | ||
|
||
IO.withTemporaryFile(s"snp-$toolName-", "args") { argFile => | ||
IO.writeLines(argFile, args) | ||
|
||
val argFileArg = "@" + argFile.getAbsolutePath | ||
val builder = Process(Vector(javaExe, "-jar", toolLauncherJar, "-tool", toolName, argFileArg)) | ||
|
||
runForOutput(builder, log) | ||
} | ||
} | ||
|
||
// Like `ProcessBuilder.!!`, but this logs the output in case of a non-zero | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment why we need this dependency? :)
Also. How did you find this lib? It looks rather new and built for a specific use case. Will this work in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is new, and it is, indeed, built for this exact use case. 😄 I've put it into the company github/sonatype organization so that I don't have to go through the trouble of establishing an organization for myself.
The library is pure Java, and has zero dependencies, so short of Java breaking the
ToolProvider
API, I don't see why this wouldn't work for the foreseeable future. And, since the library itself is a hundred lines of Java code under the MIT license, it should be reasonably easy to update/fix/rewrite it if the unthinkable happens. That is, if we stil have to support Java 8 by that point. 😄