sbt/sbt-multi-release-jar

Name: sbt-multi-release-jar

Owner: sbt

Description: Support for JDK9's Multi Release JAR Files (JEP 238)

Created: 2017-08-16 04:07:56.0

Updated: 2017-10-12 20:28:26.0

Pushed: 2017-12-15 15:58:39.0

Homepage:

Size: 55

Language: Scala

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

sbt-multi-release-jar

Download Build Status

Provides support for JEP 238: Multi-Release JAR Files. Note that this plugin is not building the jar itself, but just making sure to compile using the right JDK version files which live under src/[test|main]/[java|scala]-jdk9. The packaging into a JAR you can still us eyour favourite plugin of choice, such as sbt-assembly or others.

Usage
btPlugin("com.lightbend.sbt" % "sbt-multi-release-jar" % "0.1.2")

This plugin allows you to keep “Java 9 only” sources in:

which will only be compiled (and tests would only run) if running on JDK9.

The purpose of this plugin though is not only that, it is to be able to package such classes into the special “multi-release jar format” defined by JEP-238 (see link above).

For example this allows you to implement a specific class once using pre-JDK9 features, and also separately using the JDK9+ features (like varhandles or other library additions). Assuming the such implemented class is akka.stream.impl.MagicEngine for example, you'd implement it in src/main/scala/akka/stream/impl/MagicEngine.scala and src/main/scala-jdk9/akka/stream/impl/MagicEngine.scala, and the resulting JAR will end up containing:

/stream/impl/MagicEngine.class

-INF/versions/9/akka/stream/impl/MagicEngine.class

In runtime, when Java 9 is used, the META-INF/versions/9/... class is automatically loaded instead of the “normal class”. This is a feature of the Java 9 Runtime and is transparent to the application itself. Java runtimes prior to version 9 do not know about the special meaning of these directories, and thus will simply load the “normal class” from the root of the JAR.

This summarises the main use-case of Multi-Release JARs, however feel free to read more in the JEP 238: Multi-Release JAR Files.

Maintainer

This project is maintained by Konrad @ktoso Malawski (Akka team, Lightbend)

Contributing

Yes, pull requests and opening issues is very welcome!

Please test your changes using sbt scripted.

License

This plugin is released under the Apache 2.0 License


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.