Fixing Contracts for Java, and enabling contracts by default for unit/integration tests.

The NullPointerException we were seeing when trying to run with contracts enabled was being caused
by an outdated version of the asm library.

To run tests without contracts and disable their compilation, pass in "-Duse.contracts=false" to ant.

Also did some minor unrelated cleanup in build.xml
This commit is contained in:
David Roazen 2011-07-08 15:34:39 -04:00
parent 5ed7243b64
commit a3c9d9c3ff
5 changed files with 51 additions and 27 deletions

View File

@ -28,6 +28,7 @@
<property name="build.dir" value="build" /> <property name="build.dir" value="build" />
<property name="dist.dir" value="dist" /> <property name="dist.dir" value="dist" />
<property name="lib.dir" value="lib" />
<property name="external.dir" value="external" /> <property name="external.dir" value="external" />
<property name="public.dir" value="public" /> <property name="public.dir" value="public" />
<property name="private.dir" value="private" /> <property name="private.dir" value="private" />
@ -44,11 +45,11 @@
<property name="queue-extensions.source.dir" value="${build.dir}/queue-extensions/src" /> <property name="queue-extensions.source.dir" value="${build.dir}/queue-extensions/src" />
<!-- Contracts for Java --> <!-- Contracts for Java -->
<!-- uncomment out to enable building contracts --> <!-- To disable, run with -Duse.contracts=false -->
<property name="use.contracts" value="true" /> <property name="use.contracts" value="true" />
<property name="java.contracts" value="${build.dir}/java/contracts" /> <property name="java.contracts" value="${build.dir}/java/contracts" />
<property name="cofojaDir" value="settings/repository/com.google/"/> <property name="contracts.version" value="1.0-20110609" />
<property name="cofoja.jar" value="${cofojaDir}/cofoja-1.0-20110609.jar"/> <property name="cofoja.jar" value="${lib.dir}/cofoja-${contracts.version}.jar"/>
<!-- where to find the tribble distro --> <!-- where to find the tribble distro -->
<property name="tribble.dir" value="tribble" /> <property name="tribble.dir" value="tribble" />
@ -69,7 +70,7 @@
<property environment="env"/> <property environment="env"/>
<property name="drmaa.jar" value="${env.SGE_ROOT}/lib/drmaa.jar" /> <property name="drmaa.jar" value="${env.SGE_ROOT}/${lib.dir}/drmaa.jar" />
<patternset id="java.source.pattern"> <patternset id="java.source.pattern">
<include name="${java.public.source.dir}/**/*.java" /> <include name="${java.public.source.dir}/**/*.java" />
@ -103,7 +104,7 @@
</patternset> </patternset>
<path id="external.dependencies"> <path id="external.dependencies">
<fileset dir="lib"> <fileset dir="${lib.dir}">
<patternset refid="dependency.mask" /> <patternset refid="dependency.mask" />
</fileset> </fileset>
</path> </path>
@ -128,14 +129,14 @@
<!-- ivy properties --> <!-- ivy properties -->
<property name="ivy.install.version" value="2.2.0"/> <property name="ivy.install.version" value="2.2.0"/>
<property name="ivy.home" value="${user.home}/.ant"/> <property name="ivy.home" value="${user.home}/.ant"/>
<property name="ivy.jar.dir" value="${ivy.home}/lib"/> <property name="ivy.jar.dir" value="${ivy.home}/${lib.dir}"/>
<property name="ivy.jar.file" value="ivy-${ivy.install.version}.jar"/> <property name="ivy.jar.file" value="ivy-${ivy.install.version}.jar"/>
<property name="ivy.settings.dir" value="settings"/> <property name="ivy.settings.dir" value="settings"/>
<property file="${ivy.settings.dir}/ivysettings.properties"/> <property file="${ivy.settings.dir}/ivysettings.properties"/>
<mkdir dir="lib"/> <mkdir dir="${lib.dir}"/>
<mkdir dir="${ivy.jar.dir}"/> <mkdir dir="${ivy.jar.dir}"/>
<copy file="${cofoja.jar}" toFile="lib/cofoja.jar"/>
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/${ivy.jar.file}" <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/${ivy.jar.file}"
dest="${ivy.jar.dir}/${ivy.jar.file}" dest="${ivy.jar.dir}/${ivy.jar.file}"
usetimestamp="true"/> usetimestamp="true"/>
@ -147,7 +148,7 @@
</target> </target>
<target name="init.gridengine" depends="init" if="include.gridengine"> <target name="init.gridengine" depends="init" if="include.gridengine">
<copy todir="lib" file="${drmaa.jar}"/> <copy todir="${lib.dir}" file="${drmaa.jar}"/>
</target> </target>
<target name="resolve" depends="init.resolve,init,init.gridengine" <target name="resolve" depends="init.resolve,init,init.gridengine"
@ -229,6 +230,10 @@
<equals arg1="${gatk.target}" arg2="private" casesensitive="false" /> <equals arg1="${gatk.target}" arg2="private" casesensitive="false" />
</condition> </condition>
<condition property="include.contracts">
<equals arg1="${use.contracts}" arg2="true" />
</condition>
<!-- Create the build directory structure used by compile --> <!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}"/> <mkdir dir="${build.dir}"/>
<mkdir dir="${java.classes}"/> <mkdir dir="${java.classes}"/>
@ -252,7 +257,7 @@
<target name="init.scala.compile" depends="resolve" <target name="init.scala.compile" depends="resolve"
description="Initializes the scala ant tasks from scala-compiler.jar"> description="Initializes the scala ant tasks from scala-compiler.jar">
<path id="scala.classpath"> <path id="scala.classpath">
<fileset dir="lib"> <fileset dir="${lib.dir}">
<include name="scala-compiler-*.jar"/> <include name="scala-compiler-*.jar"/>
<include name="scala-library-*.jar"/> <include name="scala-library-*.jar"/>
</fileset> </fileset>
@ -287,7 +292,7 @@
depends="gatk.compile.public.source,gatk.compile.private.source,gatk.compile.external.source" depends="gatk.compile.public.source,gatk.compile.private.source,gatk.compile.external.source"
description="compile the GATK source" /> description="compile the GATK source" />
<target name="gatk.contracts.public" depends="gatk.compile.source"> <target name="gatk.contracts.public" depends="gatk.compile.source" if="include.contracts">
<javac fork="true" memoryMaximumSize="512m" srcdir="${java.public.source.dir}" destdir="${java.contracts}" debug="true" debuglevel="lines,vars,source" tempdir="${java.io.tmpdir}" > <javac fork="true" memoryMaximumSize="512m" srcdir="${java.public.source.dir}" destdir="${java.contracts}" debug="true" debuglevel="lines,vars,source" tempdir="${java.io.tmpdir}" >
<classpath> <classpath>
<path refid="external.dependencies" /> <path refid="external.dependencies" />
@ -299,7 +304,16 @@
</javac> </javac>
</target> </target>
<target name="gatk.contracts.private" depends="gatk.compile.source" if="include.private"> <target name="check.contracts.private" depends="gatk.contracts.public">
<condition property="include.contracts.private">
<and>
<isset property="include.contracts" />
<isset property="include.private" />
</and>
</condition>
</target>
<target name="gatk.contracts.private" depends="check.contracts.private" if="include.contracts.private">
<javac fork="true" memoryMaximumSize="512m" srcdir="${java.private.source.dir}" destdir="${java.contracts}" debug="true" debuglevel="lines,vars,source" tempdir="${java.io.tmpdir}" > <javac fork="true" memoryMaximumSize="512m" srcdir="${java.private.source.dir}" destdir="${java.contracts}" debug="true" debuglevel="lines,vars,source" tempdir="${java.io.tmpdir}" >
<classpath> <classpath>
<path refid="external.dependencies" /> <path refid="external.dependencies" />
@ -312,7 +326,7 @@
</target> </target>
<target name="gatk.contracts" depends="gatk.contracts.public,gatk.contracts.private" <target name="gatk.contracts" depends="gatk.contracts.public,gatk.contracts.private"
description="create GATK contracts" if="use.contracts" /> description="create GATK contracts" if="include.contracts" />
<target name="gatk.compile" depends="tribble,init,resolve,gatk.compile.source,gatk.contracts" /> <target name="gatk.compile" depends="tribble,init,resolve,gatk.compile.source,gatk.contracts" />
@ -452,7 +466,7 @@
<target name="init.jar" depends="sting.compile,extracthelp"> <target name="init.jar" depends="sting.compile,extracthelp">
<mkdir dir="${dist.dir}"/> <mkdir dir="${dist.dir}"/>
<copy todir="${dist.dir}"> <copy todir="${dist.dir}">
<fileset dir="lib" includes="*.jar"/> <fileset dir="${lib.dir}" includes="*.jar"/>
</copy> </copy>
</target> </target>
@ -663,7 +677,7 @@
<path refid="external.dependencies" /> <path refid="external.dependencies" />
<pathelement location="${java.classes}"/> <pathelement location="${java.classes}"/>
<pathelement location="${java.contracts}"/> <pathelement location="${java.contracts}"/>
<pathelement location="lib/testng-5.14.1.jar"/> <pathelement location="${lib.dir}/testng-5.14.1.jar"/>
</classpath> </classpath>
<compilerarg value="-proc:none"/> <compilerarg value="-proc:none"/>
<!-- <!--
@ -687,7 +701,7 @@
<path refid="scala.dependencies"/> <path refid="scala.dependencies"/>
<pathelement location="${scala.test.classes}"/> <pathelement location="${scala.test.classes}"/>
<pathelement location="${java.test.classes}"/> <pathelement location="${java.test.classes}"/>
<pathelement location="lib/testng-5.14.1.jar"/> <pathelement location="${lib.dir}/testng-5.14.1.jar"/>
</classpath> </classpath>
</scalac> </scalac>
</target> </target>
@ -727,9 +741,13 @@
<equals arg1="${pipeline.run}" arg2="$${pipeline.run}" /> <equals arg1="${pipeline.run}" arg2="$${pipeline.run}" />
</condition> </condition>
<condition property="cofoja.jvm.args" value="-javaagent:${cofoja.jar} -Dcom.google.java.contract.log.contract=false" else="">
<isset property="include.contracts" />
</condition>
<mkdir dir="${report}/@{testtype}"/> <mkdir dir="${report}/@{testtype}"/>
<echo message="Sting: Running @{testtype} test cases!"/> <echo message="Sting: Running @{testtype} test cases!"/>
<taskdef resource="testngtasks" classpath="lib/testng-5.14.1.jar"/> <taskdef resource="testngtasks" classpath="${lib.dir}/testng-5.14.1.jar"/>
<testng outputDir="${report}/@{testtype}" <testng outputDir="${report}/@{testtype}"
haltOnFailure="false" failureProperty="test.failure" haltOnFailure="false" failureProperty="test.failure"
verbose="2" verbose="2"
@ -740,9 +758,7 @@
<jvmarg value="-Djava.awt.headless=true" /> <jvmarg value="-Djava.awt.headless=true" />
<jvmarg value="-Dpipeline.run=${pipeline.run}" /> <jvmarg value="-Dpipeline.run=${pipeline.run}" />
<jvmarg value="-Djava.io.tmpdir=${java.io.tmpdir}" /> <jvmarg value="-Djava.io.tmpdir=${java.io.tmpdir}" />
<!-- needs to be if --> <jvmarg line="${cofoja.jvm.args}"/>
<!--jvmarg value="-javaagent:lib/cofoja.jar"/-->
<!--jvmarg value="-Dcom.google.java.contract.log.contract=false"/-->
<!-- <jvmarg value="-Xdebug"/> --> <!-- <jvmarg value="-Xdebug"/> -->
<!-- <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/> --> <!-- <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/> -->
<classpath> <classpath>
@ -820,7 +836,7 @@
<!-- copy the compiled library --> <!-- copy the compiled library -->
<target name="tribble.compile.copy" description="Copies the compiled tribble library" depends="tribble.compile" if="tribble.compile.exists"> <target name="tribble.compile.copy" description="Copies the compiled tribble library" depends="tribble.compile" if="tribble.compile.exists">
<copy todir="lib"> <copy todir="${lib.dir}">
<fileset dir="${tribble.dir}/dist" includes="*.jar"/> <fileset dir="${tribble.dir}/dist" includes="*.jar"/>
</copy> </copy>
</target> </target>
@ -828,7 +844,7 @@
<!-- copy the precompiled library --> <!-- copy the precompiled library -->
<target name="tribble.library.copy" description="Copies the precompiled tribble library" depends="tribble.init" unless="tribble.compile.exists"> <target name="tribble.library.copy" description="Copies the precompiled tribble library" depends="tribble.init" unless="tribble.compile.exists">
<echo message="Copying the Tribble Library..."/> <echo message="Copying the Tribble Library..."/>
<copy todir="lib"> <copy todir="${lib.dir}">
<fileset dir="settings/repository/org.broad" includes="tribble*.jar"/> <fileset dir="settings/repository/org.broad" includes="tribble*.jar"/>
</copy> </copy>
</target> </target>
@ -921,8 +937,8 @@
<pathconvert property="required.picard.jars" pathsep=":"> <pathconvert property="required.picard.jars" pathsep=":">
<fileset dir="${basedir}"> <fileset dir="${basedir}">
<include name="staging" /> <include name="staging" />
<include name="lib/picard-*.*.*.jar" /> <include name="${lib.dir}/picard-*.*.*.jar" />
<include name="lib/sam-*.jar" /> <include name="${lib.dir}/sam-*.jar" />
</fileset> </fileset>
</pathconvert> </pathconvert>
<echo message="required.picard.jars=${required.picard.jars}" /> <echo message="required.picard.jars=${required.picard.jars}" />
@ -944,7 +960,7 @@
<!-- Find bug tasks --> <!-- Find bug tasks -->
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
<path id="findbugs.classpath"> <path id="findbugs.classpath">
<fileset dir="lib" erroronmissingdir="true" includes="*.jar"/> <fileset dir="${lib.dir}" erroronmissingdir="true" includes="*.jar"/>
</path> </path>
<target name="findbugs" depends="dist"> <target name="findbugs" depends="dist">
<antcall target ="resolve"> <antcall target ="resolve">
@ -969,7 +985,7 @@
<target name="clean" description="clean up" depends="tribble.clean,clean.javadoc"> <target name="clean" description="clean up" depends="tribble.clean,clean.javadoc">
<delete dir="out"/> <delete dir="out"/>
<delete dir="${build.dir}"/> <delete dir="${build.dir}"/>
<delete dir="lib"/> <delete dir="${lib.dir}"/>
<delete dir="staging"/> <delete dir="staging"/>
<delete dir="${dist.dir}"/> <delete dir="${dist.dir}"/>
<delete dir="pipelinetests"/> <delete dir="pipelinetests"/>

View File

@ -60,6 +60,10 @@
<dependency org="net.sourceforge.findbugs" name="jsr305" rev="1.3.2" conf="test"/> <dependency org="net.sourceforge.findbugs" name="jsr305" rev="1.3.2" conf="test"/>
<dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT" conf="test" /> <dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT" conf="test" />
<!-- Contracts for Java and dependencies -->
<dependency org="com.google.code.cofoja" name="cofoja" rev="1.0-20110609" />
<dependency org="asm" name="asm-all" rev="3.3.1" />
<!-- POI, for reading pipeline files --> <!-- POI, for reading pipeline files -->
<dependency org="org.apache.poi" name="poi" rev="3.8-beta3" /> <dependency org="org.apache.poi" name="poi" rev="3.8-beta3" />
<dependency org="org.apache.poi" name="poi-ooxml" rev="3.8-beta3" /> <dependency org="org.apache.poi" name="poi-ooxml" rev="3.8-beta3" />

View File

@ -25,5 +25,6 @@
<module organisation="javax.activation" resolver="java.net" /> <module organisation="javax.activation" resolver="java.net" />
<module organisation="net.java.dev.jna" resolver="maven2-repository.dev.java.net" /> <module organisation="net.java.dev.jna" resolver="maven2-repository.dev.java.net" />
<module organisation="com.google.code.caliper" resolver="projects" /> <module organisation="com.google.code.caliper" resolver="projects" />
<module organisation="com.google.code.cofoja" resolver="projects" />
</modules> </modules>
</ivysettings> </ivysettings>

View File

@ -0,0 +1,3 @@
<ivy-module version="1.0">
<info organisation="com.google.code.cofoja" module="cofoja" revision="1.0-20110609" status="integration" publication="20110609114800" />
</ivy-module>