JAL-1888 compile tests to separate directory and pass directly as fileset to testNG...
[jalview.git] / build.xml
index d0aad96..a517ec2 100755 (executable)
--- a/build.xml
+++ b/build.xml
@@ -19,7 +19,7 @@
 -->
 <project name="jalviewX" default="usage" basedir=".">
   <target name="help" depends="usage" />
-  <target name="usage">
+  <target name="usage" depends="init">
     <echo message="~~~Jalview Ant build.xml Usage~~~~" />
     <echo message="Targets include:" />
     <echo message="usage - default target, displays this message" />
@@ -30,6 +30,8 @@
     <echo message="              this needs a keystore and key. See docs/building.html for more information." />
     <echo message="compileApplet - compiles all necessary files for Applet" />
     <echo message="makeApplet - compiles, then packages and obfuscates the Applet" />
+    <echo message="testng - run jalview's tests via testNG. Default group is '${testng-groups}'" />
+    <echo message="      you can specify particular test groups as a list via -Dtestng-groups=" />
     <echo message="See docs/building.html and the comments in build file for other targets." />
     <echo message="note: compile and makeApplet require the property java118.home to be set to point to a java 1.1.8 jdk." />
     <echo message="Useful -D flags: -Ddonotobfuscate will prevent applet obfuscation" />
@@ -80,6 +82,8 @@
     <property name="jalview.key" value="jalview" />
     <!-- Key Password -->
     <property name="jalview.key.pass" value="alignmentisfun" />
+    
+    <property name="testng-groups" value="Functional"/>
 
     <!-- Don't change anything below here unless you know what you are doing! -->
     <!-- Url path for WebStart in JNLP file -->
         <include name="${jmolJar}" />
         <include name="${varnaJar}" />
       </fileset>
-
+    </path>
+    <path id="test.classpath">
+      <pathelement path="${outputDir}" />
+      <path refid="build.classpath" />
     </path>
     <property name="source.dist.name" value="${basedir}/jalview-src.tar.gz" />
     <!-- The Location of the java 1.1.8 jdk -->
     <tstamp prefix="build">
       <format property="date" pattern="dd MMMM yyyy" />
     </tstamp>
+    <exec executable="/usr/bin/git" outputproperty="git.commit"  failifexecutionfails="false">
+      <arg value="rev-parse"/>
+      <arg value="--short"/>
+      <arg value="HEAD"/>
+    </exec>
+    <exec executable="/usr/bin/git" outputproperty="git.branch" failifexecutionfails="false">
+      <arg value="rev-parse"/>
+      <arg value="--abbrev-ref"/>
+      <arg value="HEAD"/>
+    </exec>
     <properties file="${outputDir}/.build_properties">
       <header>
           ---Jalview Build Details---
         </header>      
       <property name="VERSION" value="${JALVIEW_VERSION}" />
-      <property name="INSTALLATION" value="${INSTALLATION}" />
+      <property name="INSTALLATION" value="${INSTALLATION} git-commit:${git.commit} [${git.branch}]" />
       <property name="BUILD_DATE" value="${build.date}" />
     </properties>
   </target>
   <target name="testclean" depends="init">
     <delete dir="${testOutputDir}" includes="*,**/*"/>
   </target>
-  
-  <target name="prepareTests" depends="init">
-       <mkdir dir="${testOutputDir}" />
-       <copy todir="${testOutputDir}">
-               <fileset dir=".">
-                       <include name="${docDir}/**/*.*" />
-                       <include name="${helpDir}/**/*.*" />
-                       <include name="${libDir}/*.jar" />
-               </fileset>
-               <fileset dir="${resourceDir}">
-                       <include name="**/*.*" />
-               </fileset>
-       </copy>
-  </target>  
-  
-  <target name="buildTests" depends="prepareTests">
-       <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${testOutputDir}"
-               debug="${javac.debug}" classpathref="build.classpath" includeantruntime="false" >               
-       </javac>
-       <javac source="${javac.source}" target="${javac.target}" srcdir="${testDir}" destdir="${testOutputDir}"
-               debug="${javac.debug}" classpathref="build.classpath" includeantruntime="false" >
-       </javac>
+
+  <target name="prepareTests" depends="init,clean">
+    <mkdir dir="${testOutputDir}" />
   </target>
-  
-  <taskdef name="testng" classname="org.testng.TestNGAntTask" >            
-       <classpath location="utils/testnglibs/testng.jar" />
-  </taskdef>
-  
+
+  <target name="buildTests" depends="build,buildindices,prepareTests">
+    <javac source="${javac.source}" target="${javac.target}" srcdir="${testDir}" destdir="${testOutputDir}" debug="${javac.debug}" classpathref="test.classpath" includeantruntime="false">
+    </javac>
+  </target>
+
+  <taskdef resource="testngtasks" classpath="utils/testnglibs/testng.jar" />
+
   <target name="testng" depends="buildTests">
-       <testng classpathref="build.classpath" outputDir="${reportDir}"
-               haltOnFailure="false">
-               <classpath location="${testOutputDir}" />
-               <xmlfileset dir="utils" includes="jalview_testng.xml" />
-       </testng>
+    <testng outputDir="${reportDir}" haltOnFailure="false" groups="${testng-groups}" mode="testng">
+      <classpath>
+        <pathelement location="${testOutputDir}" />
+        <path refid="test.classpath" />
+      </classpath>
+      <classfileset dir="${testOutputDir}" includes="**/*.class" />
+    </testng>
   </target>
-  
+
   <target name="buildindices" depends="init, prepare" unless="help.uptodate">
     <java classname="com.sun.java.help.search.Indexer" classpathref="build.classpath" fork="true" dir="${outputDir}/${helpDir}">
       <arg line="html" />
 
     <jar destfile="${packageDir}/jalview_jnlp_vm.jar" index="true">
       <fileset dir="${packageDir}">
-        <include name="JNLP-INF"/>
+        <include name="JNLP-INF/APPLICATION-TEMPLATE.JNLP" />
       </fileset>
     </jar>