ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/2] ant git commit: JEP-238: create a MultiVersion-JAR with current possibilities
Date Wed, 21 Sep 2016 12:01:41 GMT
Repository: ant
Updated Branches:
  refs/heads/master e843dd287 -> 6b17b4cf6


JEP-238: create a MultiVersion-JAR with current possibilities


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/af3d90cc
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/af3d90cc
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/af3d90cc

Branch: refs/heads/master
Commit: af3d90cce9d18ff6faa4f2c1513dcf32d7cb7bb8
Parents: e843dd2
Author: Jan Matèrne <jhm@apache.org>
Authored: Wed Sep 21 09:02:58 2016 +0200
Committer: Jan Matèrne <jhm@apache.org>
Committed: Wed Sep 21 09:02:58 2016 +0200

----------------------------------------------------------------------
 src/tests/antunit/taskdefs/jar-test.xml | 61 ++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/af3d90cc/src/tests/antunit/taskdefs/jar-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/taskdefs/jar-test.xml b/src/tests/antunit/taskdefs/jar-test.xml
index c2c8834..bd0026a 100644
--- a/src/tests/antunit/taskdefs/jar-test.xml
+++ b/src/tests/antunit/taskdefs/jar-test.xml
@@ -249,4 +249,65 @@ Main-Class: MyClass
         resource="${output}/META-INF/MANIFEST.MF"/>
   </target>
 
+  <target name="testMultiReleaseJar" description="http://openjdk.java.net/jeps/238">
+    <!-- Preparation of the 'MultiRelease-Project' -->
+    <property name="java8.src"  value="${input}/src/java"/>
+    <property name="java9.src"  value="${input}/src/java9"/>
+    <property name="java10.src" value="${input}/src/java10"/>
+    <property name="java8.classes"  value="${input}/build/classes"/>
+    <property name="java9.classes"  value="${input}/build/classes9"/>
+    <property name="java10.classes" value="${input}/build/classes10"/>
+    <macrodef name="create">
+      <attribute name="version" />
+      <sequential>
+        <local name="src"/>
+        <local name="classes"/>
+        <property name="src" value="${java@{version}.src}"/>
+        <property name="classes" value="${java@{version}.classes}"/>
+        <mkdir dir="${src}/org/apache/ant/test"/>
+        <echo file="${src}/org/apache/ant/test/MRJarTest.java">
+          package org.apache.ant.test;
+          public class MRJarTest {
+            public static final String VERSION = "Java@{version}";
+          }
+        </echo>
+        <mkdir dir="${classes}"/>
+        <javac srcdir="${src}" destdir="${classes}" debug="on" includeantruntime="false"/>
+      </sequential>
+    </macrodef>
+    <create version="8"/>
+    <create version="9"/>
+    <create version="10"/>
+    
+    <!-- Now create the MultiReleaseJar -->
+    <jar destfile="${antunit.tmpdir}/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="${java8.classes}"/>
+      <!-- ... per release classes, require Java9+ for loadable via standard ClassLoader
-->
+      <zipfileset prefix="META-INF/versions/9/" dir="${java9.classes}"/>
+      <zipfileset prefix="META-INF/versions/10/" dir="${java10.classes}"/>
+    </jar>
+    
+    <!-- Now some tests -->
+    <loadresource property="valueFrom8">
+      <javaconstant name="org.apache.ant.test.MRJarTest.VERSION">
+        <classpath>
+          <pathelement location="${antunit.tmpdir}/mrjar.jar"/>
+        </classpath>
+      </javaconstant>
+    </loadresource>
+    <au:assertEquals expected="Java8" actual="${valueFrom8}"/>
+    <au:assertNestedResourceExists>
+      <zipentry zipfile="${antunit.tmpdir}/mrjar.jar" name="META-INF/versions/9/org/apache/ant/test/MRJarTest.class"/>
+    </au:assertNestedResourceExists>
+    <au:assertNestedResourceExists>
+      <zipentry zipfile="${antunit.tmpdir}/mrjar.jar" name="META-INF/versions/10/org/apache/ant/test/MRJarTest.class"/>
+    </au:assertNestedResourceExists>
+  </target>
+
 </project>


Mime
View raw message