JAL-3130 Merge of JAL-3130_Java_11_investigations-Ben-2 and updated develop
[jalview.git] / build-j11.xml
similarity index 93%
rename from build.xml
rename to build-j11.xml
index 9cd966c..71fee4f 100755 (executable)
--- a/build.xml
     <condition property="java9">
       <equals arg1="${ant.java.version}" arg2="9"/>
     </condition>
+    <!-- Java 10 JVM args -->
+    <condition property="java10">
+      <equals arg1="${ant.java.version}" arg2="10"/>
+    </condition>
+    <!-- Java 11 JVM args -->
+    <condition property="java11">
+      <equals arg1="${ant.java.version}" arg2="11"/>
+    </condition>
+    <echo message="ant.java.version is ${ant.java.version}"/>
 
     <!-- Don't change anything below here unless you know what you are doing! -->
     <!-- Url path for WebStart in JNLP file -->
     <!-- Anne's version needs 1.7 - should rebuild VARNA to java 1.6 for release -->
     <property name="j2sev" value="1.7+" />
     <!-- Java Compilation settings - source and target javac version -->
-    <property name="javac.source" value="1.8" />
-    <property name="javac.target" value="1.8" />
+    <property name="javac.source" value="11" if:set="java11" />
+    <property name="javac.target" value="11" if:set="java11" />
+    <property name="javac.source" value="1.8" unless:set="java11" />
+    <property name="javac.target" value="1.8" unless:set="java11" />
+    <echo message="javac.source is ${javac.source}"/>
+    <echo message="javac.target is ${javac.target}"/>
 
     <!-- Permissions for running Java applets and applications. -->
     <!-- Defaults are those suitable for deploying jalview webstart www.jalview.org -->
 
     <!-- build directory configuration -->
     <property name="libDir" value="lib" />
+    <property name="j11libDir" value="j11lib" />
     <property name="resourceDir" value="resources" />
     <property name="helpDir" value="help" />
     <property name="docDir" value="doc" />
         <include name="*.jar" />
         <include name="**/*.jar" />
       </fileset>
+      <fileset dir="${j11libDir}">
+        <include name="*.jar" />
+        <include name="**/*.jar" />
+      </fileset>
       <fileset dir="${libDir}">
         <include name="*.jar" />
         <include name="**/*.jar" />
         <include name="${jmolJar}" />
         <include name="${varnaJar}" />
       </fileset>
+      <pathelement location="${clover.jar}" if:set="clover.jar"/>
     </path>
     <path id="test.classpath">
       <pathelement path="${outputDir}" />
 
   <target name="build" depends="prepare">
     <!-- not efficient yet. -->
-    <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" classpathref="build.classpath">
+    <!-- Echo the build.classpath
+    <pathconvert property="echoClasspath" refid="build.classpath" />
+    <echo message="build.classpath is '${echoClasspath}'" />
+    -->
+    <echo message="javac.target is '${javac.target}'" />
+    <echo message="adding -Xlint:deprecation to javac" if:set="deprecation"/>
+    <javac includeantruntime="false" source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" classpathref="build.classpath">
+      <compilerarg value="-Xlint:deprecation" if:set="deprecation" />
       <exclude name="jalview/*applet*" />
       <exclude name="jalview/appletgui/**" />
       <exclude name="com/stevesoft/**" />
   <taskdef resource="testngtasks" classpath="utils/testnglibs/testng.jar" />
 
   <target name="testng" depends="buildTests">
+    <loadfile property="j11modules" srcFile="modules"/>
+    <echo message="j11libDir is '${j11libDir}'" />
+    <echo message="j11modules is '${j11modules}'" />
     <testng outputDir="${reportDir}" haltOnFailure="false" groups="${testng-groups}" mode="testng"
       verbose="2">
       <classpath>
         <pathelement location="${clover.jar}" if:set="clover.jar"/>
         <path refid="test.classpath" />
       </classpath>
+      <jvmarg value="--module-path=${j11libDir}:${java.home}/jmods" if:set="java11"/>
+      <jvmarg value="--add-modules=${j11modules}" if:set="java11"/>
       <jvmarg value="--add-modules=java.se.ee" if:set="java9"/>
       <jvmarg value="--illegal-access=warn" if:set="java9"/>
       <classfileset dir="${testOutputDir}" includes="**/*.class" />
     </testng>
   </target>
 
+  <target name="testngclass" depends="buildTests">
+    <condition property="propsSpecified">
+      <isset property="class.name" />
+    </condition>
+    <fail unless="propsSpecified" message="class.name property not specified."/>
+    <echo message="testng-groups is '${testng-groups}'" />
+    <loadfile property="j11modules" srcFile="modules"/>
+    <testng outputDir="${reportDir}" haltOnFailure="false" groups="${testng-groups}" mode="testng" verbose="2">
+      <classpath>
+        <pathelement location="${testOutputDir}" />
+        <pathelement location="${clover.jar}" if:set="clover.jar"/>
+        <path refid="test.classpath" />
+      </classpath>
+      <jvmarg value="--module-path=${j11libDir}:${java.home}/jmods" if:set="java11"/>
+      <jvmarg value="--add-modules=${j11modules}" if:set="java11"/>
+      <jvmarg value="--add-modules=java.se.ee" if:set="java9"/>
+      <jvmarg value="--illegal-access=warn" if:set="java9"/>
+      <classfileset dir="${testOutputDir}" includes="${class.name}" />
+    </testng>
+  </target>
+
   <target name="buildindices" depends="init, prepare" unless="help.uptodate">
     <replace value="${JALVIEW_VERSION}">
       <replacetoken><![CDATA[$$Version-Rel$$]]></replacetoken>