Skip to content
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

Add jdeps options settings to the jlink plugin #1225

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import sbt._
* Available settings/tasks for the [[com.typesafe.sbt.packager.archetypes.jlink.JlinkPlugin]].
*/
private[packager] trait JlinkKeys {
val jdepsOptions =
SettingKey[Seq[String]]("jdepsOptions", "Options for the jdeps utility")

val jlinkBundledJvmLocation =
TaskKey[String]("jlinkBundledJvmLocation", "The location of the resulting JVM image")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ object JlinkPlugin extends AutoPlugin {
target in jlinkBuildImage := target.value / "jlink" / "output",
jlinkBundledJvmLocation := "jre",
bundledJvmLocation := Some(jlinkBundledJvmLocation.value),
jdepsOptions := Seq("-R", "--print-module-deps"),
jlinkOptions := (jlinkOptions ?? Nil).value,
jlinkOptions ++= {
val log = streams.value.log
val run = runJavaTool(javaHome.in(jlinkBuildImage).value, log) _

val paths = fullClasspath.in(Compile).value.map(_.data.getPath)
val modules =
(run("jdeps", "-R" +: "--print-module-deps" +: paths) !! log).trim
(run("jdeps", jdepsOptions.value ++ paths) !! log).trim
.split(",")

JlinkOptions(addModules = modules, output = Some(target.in(jlinkBuildImage).value))
Expand Down