diff --git a/manual/Tasks/jar.html b/manual/Tasks/jar.html index 1df2ee03c..6920eff55 100644 --- a/manual/Tasks/jar.html +++ b/manual/Tasks/jar.html @@ -90,6 +90,11 @@ to a value other than its default, "add".

To cryptographically sign your JAR file, use the SignJar task on the JAR that you create from this task.

+

For creating a simple version of a JEP-238 multi release jar, +you don't need any special tools. Just set the required manifest entry and place the files where required, as you could see +in the JEP238-example. If you want to tune this kind of jar, e.g. decreasing the size by deleting +'same' classes from the versions-branches, you have to do more ...

+

Parameters

@@ -583,6 +588,36 @@ Sealed: false + +

JEP238 example: a Multi-Release JAR Files

+

+ Here we want to create a Multi-Release JAR File according the specification + JEP-238. + It defines on top of a JAR the possibility to place additional or overwriting classes + in a jar, which are available according to the Java version you run.
+ Basically it sais, that you have to set the manifest entry Multi-Release: true + and place all additional or overwriting classes in + META-INF/versions/number/package-structure, e.g. + META-INF/versions/9/org/apache/ant/MyClass.class +

+

+ In this example we expect that the normal classes are compiled into + ${java.classes} and the Java9 classes are compiled into + ${java9.classes}. +

+
+    <jar destfile="mrjar.jar">
+      <manifest>
+        <!-- special mf-entry according to the spec -->
+        <attribute name="Multi-Release" value="true"/>
+      </manifest>
+      <!-- directory structure according to the spec ... -->
+      <!-- ... default classes loadable by old (<Java9) versions -->
+      <fileset dir="${java.classes}"/>
+      <!-- ... per release classes, require Java9+ for loadable via standard ClassLoader -->
+      <zipfileset prefix="META-INF/versions/9/" dir="${java9.classes}"/>
+    </jar>
+
diff --git a/src/tests/antunit/taskdefs/jar-test.xml b/src/tests/antunit/taskdefs/jar-test.xml index bd0026a77..f1206edc0 100644 --- a/src/tests/antunit/taskdefs/jar-test.xml +++ b/src/tests/antunit/taskdefs/jar-test.xml @@ -301,7 +301,13 @@ Main-Class: MyClass - + + + + + + +