JAL-1888 compile tests to separate directory and pass directly as fileset to testNG...
[jalview.git] / build.xml
index 6227d06..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 -->
     <!-- J2SE version needed for webstart launch -->
     <!-- 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.7"/>
+       <property name="javac.target" value="1.7"/>
+               
     <!-- Permissions for running Java applets and applications. -->
     <!-- Defaults are those suitable for deploying jalview webstart www.jalview.org -->
     <property name="application.codebase" value="*.jalview.org" />
     <property name="packageDir" value="dist" />
     <property name="outputJar" value="jalview.jar" />
     <!-- Jalview Applet JMol Jar Dependency -->
-    <property name="jmolJar" value="JmolApplet-14.2.14_2015.06.01.jar" />
-    <property name="varnaJar" value="VARNAv3-91.jar" />
+    <property name="jmolJar" value="JmolApplet-14.2.14_2015.06.11.jar" />
+    <property name="varnaJar" value="VARNAv3-93.jar" />
     <property name="jsoup" value="jsoup-1.8.1.jar" />
     <property name="jsonSimple" value="json_simple-1.1.jar" />
     <property name="javaJson" value="java-json.jar" />
     <property name="jalviewLiteJar" value="jalviewApplet.jar" />
+       <property name="reportDir" value="test-reports" />
+       <property name="testDir" value="test" />
+       <property name="testOutputDir" value="tests" />
     <!-- switch to indicate if we should obfuscate jalviewLite -->
     <!-- <property name="donotobfuscate" value="true"/> -->
     <!-- switch to exclude associations from generated jnlp files -->
         <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="build" depends="prepare">
     <!-- not efficient yet. -->
-    <javac source="1.5" target="1.5" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" classpathref="build.classpath">
+    <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" classpathref="build.classpath">
       <exclude name="jalview/*applet*" />
       <exclude name="jalview/appletgui/**" />
       <exclude name="com/stevesoft/**" />
     </javac>
   </target>
+  
+  
+  <target name="testclean" depends="init">
+    <delete dir="${testOutputDir}" includes="*,**/*"/>
+  </target>
+
+  <target name="prepareTests" depends="init,clean">
+    <mkdir dir="${testOutputDir}" />
+  </target>
+
+  <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 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>
 
 
 <target name="compileApplet" depends="init,clean">
   <mkdir dir="${outputDir}" />
-  <javac source="1.5" target="1.5" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" 
+  <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" 
                        classpathref="jalviewlite.deps" includes="jalview/appletgui/**"
-                       excludes="ext/**,MCview/**,org/**,vamsas/**,jalview/ext/paradise/**" />
+                       excludes="ext/**,gui/**,jbgui/**,MCview/**,org/**,vamsas/**,jalview/ext/rbvi/**,jalview/ext/paradise/**" />
 </target>
 
 <target name="packageApplet" depends="compileApplet, buildPropertiesFile">