rules_java icon indicating copy to clipboard operation
rules_java copied to clipboard

Add support for building Multi-Release JARs

Open schroederc opened this issue 7 years ago • 9 comments

Description of the problem / feature request:

Add support for building JEP 238-compliant jars for distribution.

Feature requests: what underlying problem are you trying to solve with this feature?

  • http://openjdk.java.net/jeps/238#Motivation.
  • https://github.com/protocolbuffers/protobuf/issues/3781 is one concrete example of a desire for JEP 238 support in Bazel.

schroederc avatar Aug 21 '18 15:08 schroederc

Alternatively, consider variant-aware dependency management similarly to what Gradle are considering.

jbduncan avatar Aug 22 '18 20:08 jbduncan

This is really useful for projects that want to use the Java Platform Module System but remain backward compatible (such as Selenium).

The module-info needs to be compiled to target Java 9. Some apps freak out when they find a java class with an "incorrect" java version in a jar, meaning that it's not safe to mix-and-match class files targeting both Java 8 and 9+ in the same JAR, unless we use the multi-release capability.

shs96c avatar Mar 28 '19 11:03 shs96c

On a related note, is there a plan to support consuming multi release JARs using the jvm_maven_import_external rule? I can open a separate issue for this if needed.

rohanag12 avatar Mar 28 '19 18:03 rohanag12

A cheap win would be to place code targeting JRE's later than 8 in multi-release jar compatible locations. That would basically provide all the support that most projects would need when creating JARs (though it will make shadowing trickier)

shs96c avatar Mar 29 '19 11:03 shs96c