Skip to content
Permalink
Browse files
Add support for Multi-Release JAR assembly
Extend the assembled JAR to allow multiple, Java-release-specific
versions of class files to coexist in a single archive.

See JEP-238.
  • Loading branch information
davecromberge committed Jun 17, 2021
1 parent b1cda03 commit 352dddd6ac4daa196dd3e4aea7d8388be92c04ae
Showing 6 changed files with 60 additions and 2 deletions.
@@ -69,6 +69,13 @@ This will create the following Jars:
* datasketches-memory-X.Y.Z-test-sources.jar The test source files
* datasketches-memory-X.Y.Z-javadoc.jar The compressed Javadocs.

### Further documentation for contributors

For more information on the project configuration, the following topics are discussed in more detail:

* [Maven configuration](docs/maven.md)
* [Multi-release jar](docs/multi-release-jar.md)

### Dependencies

#### Run-time
@@ -110,7 +110,7 @@
</configuration>
<executions>

<!-- primary jar -->
<!-- multi-release (MR) jar -->
<execution>
<id>assemble-jar</id>
<phase>package</phase>
@@ -121,7 +121,7 @@
<appendAssemblyId>false</appendAssemblyId>
<attach>true</attach>
<descriptors>
<descriptor>src/assembly/assemble-jar.xml</descriptor>
<descriptor>src/assembly/assemble-mr-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>
@@ -28,6 +28,7 @@

<!-- Compiled java classes from dependency modules -->
<moduleSets>
<!-- java8 -->
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
@@ -43,6 +44,23 @@
</fileSets>
</sources>
</moduleSet>
<!-- java9 -->
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>org.apache.datasketches:datasketches-memory-java9</include>
</includes>
<binaries>
<outputDirectory>META-INF/versions/9</outputDirectory>
<unpack>true</unpack>
<includeDependencies>false</includeDependencies>
<unpackOptions>
<excludes>
<exclude>/META-INF/**</exclude>
</excludes>
</unpackOptions>
</binaries>
</moduleSet>
</moduleSets>

<fileSets>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,33 @@
Multi-release JAR
=================

The `datasketches-memory` module assembles a JAR for release that consists of multiple Java-release-specific versions
of class files to coexist in a single archive (the MR-JAR).

From [JEP-238](https://openjdk.java.net/jeps/238):

> Third party libraries and frameworks typically support a range of Java platform versions, generally going several
versions back. As a consequence they often do not take advantage of language or API features available in newer
releases since it is difficult to express conditional platform dependencies, which generally involves reflection, or
to distribute different library artifacts for different platform versions.
And, specifically for libraries like `datasketches-memory`:

> Some libraries and frameworks, furthermore, use internal APIs of the JDK that will be made inaccessible in Java 9
when module boundaries are strictly enforced. This also creates a disincentive to support new platform versions when
there are public, supported API replacements for such internal APIs.
MR-JAR Assembly
---------------

The maven assembly plugin uses the following maven submodules to source the compiled class files for the MR-JAR:

![MR-JAR maven module mapping](img/mr-jar-sources.png "MR-JAR maven module mapping")

MR-JAR Manifest
---------------

The maven-assembly plugin Assembly plugin copies version specific class files into JAR manifest META-INF directory, as
shown in the diagram below:

![MR-JAR manifest file contents](img/mr-jar-manifest.png "MR-JAR manifest file contents")

0 comments on commit 352dddd

Please sign in to comment.