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

Conversation

vhiairrassary
Copy link

I just tested the jlink wrapper for my project but jdeps produced some not found for some classes:

Error: Missing dependencies from the module path and classpath.
To suppress this error, use --ignore-missing-deps to continue.

shapeless_2.12-2.3.3.jar
   shapeless.CachedImplicitMacros                     -> scala.reflect.macros.contexts.Context              not found
   shapeless.CachedImplicitMacros                     -> scala.tools.nsc.Global                             not found
   shapeless.CachedImplicitMacros                     -> scala.tools.nsc.typechecker.Analyzer               not found
   shapeless.CachedImplicitMacros                     -> scala.tools.nsc.typechecker.Contexts               not found
[...]

This PR adds a way to set or add options for jdeps. I tested on mac using java 12 and:

jlinkOptions ++= Seq("--no-header-files", "--no-man-pages", "--compress=2", "--strip-debug"),
jdepsOptions ++= Seq("--ignore-missing-deps")

/cc @nigredo-tori

@nigredo-tori
Copy link
Collaborator

nigredo-tori commented May 14, 2019

The actual problem with your build is that shapeless has a Provided dependency on scala-reflect, which is not satisfied. You should probably fix that instead, even more so since --ignore-missing-deps would also silence other similar errors.

That said, it seems like the behavior of jdeps has changed in JDK 12, hence this issue. jdepsOptions is fine as a stopgap, but it ties the build to a specific JDK version. This setting also seems like an easy way to inadvertedly break things (by losing --print-module-deps).

Ideally, we want to catch any missing dependencies, but we also want to give users the option to ignore these with arbitrary granularity. I'm thinking something along the lines of

val jlinkSilenceMissingDependency: SettingKey[(String, String) => Boolean]

As for the implementation, we can leverage --ignore-missing-deps/--missing-deps for JDK12 (I think - I haven't tried these out yet). However, for JDK 11 we have to parse the full jdeps output, so we can probably use this implementation for both cases.

Obviously, this would be more involved than jdepsOptions, and it would require additional tests.

@vhiairrassary
Copy link
Author

You are right 👍I will close this PR then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants