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

Fix deployable JARs created by Scala rules. #61

Merged
merged 1 commit into from
May 23, 2016
Merged

Fix deployable JARs created by Scala rules. #61

merged 1 commit into from
May 23, 2016

Conversation

devnev
Copy link
Contributor

@devnev devnev commented May 23, 2016

"Deployable" Jars, as created by the java_binary rule, are Jars with all runtime dependencies included. These are usable as standalone Jars that can be deployed onto servers and such. The reason why we need these for Scala binaries and libraries is as a bandaid fix for Java/Scala interop in Bazel. The Java ecosystem of rules is closed: AFAICT, only known-good rules (cc_library, java_library, java_import, ...) can be used as dependencies of java libraries and binaries. To work around this, the scala_export_to_java macro injects scala into the java ecosystem via "precompiled" jars in the java_imports rule. However, this rule does not pick up transitive runtime dependencies of the imported Jars, so when using these Jars in java_tests, the tests fail because they do not have access to the runtime dependencies of the imported Scala Jar. To make these imports work, the imported Jar must therefore be one that includes the full runtime dependencies in the Jar itself, which is what correctly-built "deploy" Jars provide.

@bazel-io
Copy link
Member

Can one of the admins verify this patch?

@dinowernli
Copy link
Contributor

This looks legit to me, but please wait for one of @johnynek to ack.

@johnynek
Copy link
Member

This looks good, and fixes #20 #25 . I do have anxiety that these jars may be quite big, and have a lot of duplication, so actually solving #57 is still worth doing if that is your goal.

Also note, due to #53 , on OSX, jar is not respecting timestamps, so each run invalidates the cache, which is a real bummer. A fix for that will have fix this code as well.

@johnynek johnynek merged commit 1e80999 into bazelbuild:master May 23, 2016
@johnynek
Copy link
Member

@devnev thanks for your contribution!

@johnynek
Copy link
Member

@devnev we are having some issues with this PR. It significantly increases the build time for all our targets.

We need to find a way to deal with this. Is it the case that you only want the scala_to_java_export to work correctly? If so, we can fix that to actually compute the real deps and not generate the deploy jar for all libraries. It seems that in bazel, deploy jars are only implicit outputs of java_binary so maybe we should follow that approach and not build them for scala_library.

@johnynek
Copy link
Member

also, see issue bazelbuild/bazel#970

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

Successfully merging this pull request may close these issues.

None yet

5 participants