JAL-1645 Version-Rel Version 2.9 Year-Rel 2015 Licensing glob
[jalview.git] / build.xml
index 1ac7afc..de0d7a8 100755 (executable)
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9)
+ * Copyright (C) 2015 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * The Jalview Authors are detailed in the 'AUTHORS' file.
 -->
 <project name="jalviewX" default="usage" basedir=".">
-  <!-- we use jalopy to format our sources -->
-  <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
-    <classpath>
-      <fileset dir="utils/jalopy/lib">
-        <include name="*.jar" />
-      </fileset>
-    </classpath>
-  </taskdef>
-
   <target name="help" depends="usage" />
   <target name="usage">
     <echo message="~~~Jalview Ant build.xml Usage~~~~" />
         <include name="*.jar"/>
       </fileset> -->
       </path>
+       
     <!-- Jalview Version String displayed by application on startup and used to check for updates -->
     <property name="JALVIEW_VERSION" value="DEVELOPMENT" />
+       
+    <property name="INSTALLATION" value="Source" />
+       
     <!-- 2.4 (VAMSAS)" -->
     <!-- Include debugging information in javac true or false -->
     <property name="javac.debug" value="true" />
     <!-- Key Password -->
     <property name="jalview.key.pass" value="alignmentisfun" />
 
-
-
     <!-- Don't change anything below here unless you know what you are doing! -->
     <!-- Url path for WebStart in JNLP file -->
     <property name="WebStartLocation" value="http://www.jalview.org/webstart" />
     <!-- Webstart Image - looked for in resources/images -->
     <property name="WebStartImage" value="JalviewLogo_big.png"/>
     <!-- J2SE version needed for webstart launch -->
-    <property name="j2sev" value="1.6+"/>
-
+    <!-- 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-12.2.4.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 -->
         <!-- the JmolApplet includes the JmolApplet console and the application javac seems to always try and build all packages 
                                -->
         <include name="${jmolJar}" />
+        <include name="${varnaJar}" />
       </fileset>
 
     </path>
     <property name="source.dist.name" value="${basedir}/jalview-src.tar.gz" />
     <!-- The Location of the java 1.1.8 jdk -->
-    <!--<property name="java118.home" value="C:\Sun\jdk1.1.8" />
-               -->
+    <!--<property name="java118.home" value="C:\Sun\jdk1.1.8" /> -->
     <property name="java118.home" value="${java.home}" />
-    <!--<property name="applet.jre.tools" value="${java118.home}/lib/classes.zip" />
+    <!-- <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip" />
                -->
     <!-- jre for 1.4 version -->
     <property name="applet.jre.tools" value="${java.home}/lib/rt.jar"/>
         <include name="plugin.jar"/>
       </fileset>
       <pathelement location="appletlib/${jmolJar}" />
+      <pathelement location="lib/${varnaJar}" />
+      <pathelement location="lib/${jsoup}" />
+      <pathelement location="lib/${jsonSimple}" />
+      <pathelement location="lib/${javaJson}" />
+      
     </path>
     <!-- default location for outputting javadoc -->
     <property name="javadocDir" value="${packageDir}/javadoc"/>
     <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>
+        </header>      
       <property name="VERSION" value="${JALVIEW_VERSION}" />
+      <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">
+       <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>
+  
+  <taskdef name="testng" classname="org.testng.TestNGAntTask" >            
+       <classpath location="utils/testnglibs/testng.jar" />
+  </taskdef>
+  
+  <target name="testng" depends="buildTests">
+       <testng classpathref="build.classpath" outputDir="${reportDir}"
+               haltOnFailure="false">
+               <classpath location="${testOutputDir}" />
+               <xmlfileset dir="utils" includes="jalview_testng.xml" />
+       </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" />
             <include name="*.jar" />
             <include name="*_*.jar" />
             <exclude name="jalview.jar" />
+               <exclude name="*jnilib.jar"/>
           </fileset>
+       </resources>
+        <resources os="Mac OS X">
           <property name="jalview.version" value="${JALVIEW_VERSION}" />
+               <fileset dir="${packageDir}">
+                       <include name="*quaqua*.jnilib.jar"/>
+               </fileset>
         </resources>
+       
         <application_desc main_class="jalview.bin.Jalview">
         </application_desc>
         <security>
     </presetdef>
 
     <jnlpf toFile="${jnlpFile}"/>
-  
+
   </target>
-  
+
   <target name="-dofakejnlpfileassoc" depends="-generatejnlpf" if="nojnlpfileassocs">
     <echo message="Not adding JNLP File Associations"/>
   </target>
-  
+
   <target name="-dojnlpfileassoc" depends="-generatejnlpf" unless="nojnlpfileassocs">
     <replace file="${jnlpFile}">
       <replacetoken>
         <association mime-type="application-x/ext-file" extensions="stk"/>
         <association mime-type="application-x/ext-file" extensions="jvp"/>
       </information>]]></replacevalue>
-    </replace>
-    <echo message="Added file associations to JNLP file"/>
-    </target>
+  </replace>
+  <echo message="Added file associations to JNLP file"/>
+</target>
 <target name="writejnlpf" depends="-dojnlpfileassoc,-dofakejnlpfileassoc">
 </target>
 
 
 <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/**" />
+                       excludes="ext/**,gui/**,jbgui/**,MCview/**,org/**,vamsas/**,jalview/ext/rbvi/**,jalview/ext/paradise/**" />
 </target>
 
 <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
   <path id="obfuscateDeps.path">
     <pathelement location="${applet.jre.tools}" />
     <pathelement location="appletlib/${jmolJar}" />
+    <pathelement location="appletlib/${jsonSimple}" />
+    <pathelement location="appletlib/${javaJson}" />
   </path>
   <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
 
     </fileset>
   </copy>
   <jar update="true" index="true" jarfile="${packageDir}/examples/${jalviewLiteJar}"/>
+  <jar update="true" index="true" jarfile="${packageDir}/examples/${javaJson}"/>
+  <jar update="true" index="true" jarfile="${packageDir}/examples/${jsonSimple}"/>
   <jar update="true" index="true" jarfile="${packageDir}/examples/${jmolJar}">
     <manifest>
       <attribute name="Application-Name" value="Jmol (bundled with JalviewLite)"/>
   <!-- create differently privileged artefacts -->
   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/u_${jalviewLiteJar}" />
   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true"/>
+  <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true"/>
+  <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true"/>
   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/ap_${jalviewLiteJar}" />
   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/ap_${jmolJar}"/>
+  <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/ap_${javaJson}"/>
+  <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/ap_${jsonSimple}"/>
   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jalviewLiteJar}" />
   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jmolJar}" />
+  <ap_applet.jar jarfile="${packageDir}/examples/ap_${javaJson}" />
+  <ap_applet.jar jarfile="${packageDir}/examples/ap_${jsonSimple}" />
   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/tl_${jalviewLiteJar}" />
   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/tl_${jmolJar}" />
+  <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/tl_${javaJson}" />
+  <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/tl_${jsonSimple}" />
   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jalviewLiteJar}" />
   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jmolJar}" />
+  <tl_applet.jar jarfile="${packageDir}/examples/tl_${javaJson}" />
+  <tl_applet.jar jarfile="${packageDir}/examples/tl_${jsonSimple}" />
   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/to_${jalviewLiteJar}" />
   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/to_${jmolJar}" />
+  <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/to_${javaJson}" />
+  <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/to_${jsonSimple}" />
   <to_applet.jar jarfile="${packageDir}/examples/to_${jalviewLiteJar}" />
   <to_applet.jar jarfile="${packageDir}/examples/to_${jmolJar}" />
+  <to_applet.jar jarfile="${packageDir}/examples/to_${javaJson}" />
+  <to_applet.jar jarfile="${packageDir}/examples/to_${jsonSimple}" />
   <!-- finally, create manifest for original jars -->
   <applet.jar jarfile="${packageDir}/examples/${jalviewLiteJar}" />
   <applet.jar jarfile="${packageDir}/examples/${jmolJar}" />
+  <applet.jar jarfile="${packageDir}/examples/${javaJson}" />
+  <applet.jar jarfile="${packageDir}/examples/${jsonSimple}" />
 
   <!-- todo - write examples/downloads for alternate versions of the applet -->
   <signjar storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false">
       <exclude name="u_*.jar"/>
       <include name="${jalviewLiteJar}" />
       <include name="${jmolJar}" />
+      <include name="${javaJson}" />
+      <include name="${jsonSimple}" />
       <include name="to_${jalviewLiteJar}" />
       <include name="to_${jmolJar}" />
+      <include name="to_${javaJson}" />
+      <include name="to_${jsonSimple}" />
       <include name="tl_${jalviewLiteJar}" />
       <include name="tl_${jmolJar}" />
+      <include name="tl_${javaJson}" />
+      <include name="tl_${jsonSimple}" />
       <include name="ap_${jalviewLiteJar}" />
       <include name="ap_${jmolJar}" />
+      <include name="ap_${javaJson}" />
+      <include name="ap_${jsonSimple}" />
     </fileset>
   </signjar>
   <!-- bizarre bug causes JmolApplet to always get signed, even if excluded from above. so copy explicitly -->
   <copy file="appletlib/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
+       <!-- finally, replace any launchApp servlet tags with a version specification -->
+       <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}&quot;">
+               <replacetoken><![CDATA[http://www.jalview.org/services/launchApp"]]></replacetoken>
+               <fileset dir="${packageDir}/examples">
+                       <include name="**/*.html"/>
+               </fileset>
+       </replace>
+       <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}'">
+               <replacetoken><![CDATA[http://www.jalview.org/services/launchApp']]></replacetoken>
+               <fileset dir="${packageDir}/examples">
+                       <include name="**/*.html"/>
+               </fileset>
+       </replace>
+
 </target>
 <target name="sourcedoc" description="Create jalview source documentation pages" depends="init">
   <javadoc destdir="${javadocDir}">