Skip to content
Snippets Groups Projects
build-common.xml 6.96 KiB
Newer Older
  • Learn to ignore specific revisions
  • brinn's avatar
    brinn committed
    <project name="build-common" basedir="..">
    
    kaloyane's avatar
    kaloyane committed
    	<import file="build-basic.xml" />
    
    	<property name="lib" value="../libraries" />
    	<taskdef name="build-info"
    	         classname="ch.systemsx.cisd.ant.task.subversion.GatherRevisionAndVersionTask"
    	         classpathref="build-resource.path" />
    	<taskdef name="build-java-subprojects"
    	         classname="ch.systemsx.cisd.ant.task.subprojectbuilder.BuildJavaSubprojectsTask"
    	         classpathref="build-resource.path" />
    	<taskdef name="project-classpath"
    	         classname="ch.systemsx.cisd.ant.task.SetEclipseClasspathTask"
    	         classpathref="build-resource.path" />
    	<typedef name="recursive-jar"
    	         classname="ch.systemsx.cisd.ant.task.RecursiveJar"
    	         classpathref="build-resource.path" />
    
    felmer's avatar
    felmer committed
    	<taskdef name="testng" 
    	         classname="org.testng.TestNGAntTask"  
    	         classpath="../libraries/testng/testng-jdk15.jar" />
    
    kaloyane's avatar
    kaloyane committed
    	<taskdef name="dependency-checker"
    	         classname="classycle.ant.DependencyCheckingTask"
    	         classpath="${lib}/classycle/classycle.jar" />
    
    	<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
    	<property name="server-resource" value="${resource}/server" />
    	<property name="sources" value="source/java" />
    	<property name="sources.test" value="sourceTest/java" />
    	<property name="classes" value="${targets}/ant/classes" />
    	<property name="output.test" value="${targets}/test-output" />
    	<property name="build.info.filename" value="BUILD-${ant.project.name}.INFO" />
    	<property name="build.info.file" value="${classes}/${build.info.filename}" />
    
    	<property name="log.configuration.file" location="etc/log.xml" />
    
    kaloyane's avatar
    kaloyane committed
    
    	<!-- The name of the file containing checksums for all properties files -->
    	<property name="checksum.file.name" value="configuration.MD5" />
    	<property name="checksum.file" value="${dist}/${checksum.file.name}" />
    
    	<!--
    
          // Dummy target used by cruisecontrol
          -->
    
    kaloyane's avatar
    kaloyane committed
    	<target name="_dummy" description="Dummy target used by cruisecontrol" />
    
    	<target name="prepare">
    		<delete dir="${classes}" />
    		<mkdir dir="${classes}" />
    	</target>
    
    
    	<target name="compile" unless="compile.bypass">
    
    kaloyane's avatar
    kaloyane committed
    		<build-java-subprojects target="_plain-compile-sources"/>
    		<antcall target="_plain-compile-sources" />
    	</target>
    
    	<target name="compile-tests" depends="compile">
    		<build-java-subprojects target="_plain-compile-tests"/>
    		<antcall target="_plain-compile-tests" />
    	</target>
    
    	<target name="check-dependencies" depends="compile">
    		<antcall target="check-dependencies-no-compile" />
    	</target>
    
    	<target name="check-dependencies-no-compile">
    		<dependency-checker definitionFile="resource/dependency-structure.ddf"
    		                    failOnUnwantedDependencies="true"
    		                    mergeInnerClasses="true">
    			<fileset dir="${classes}">
    				<include name="**/*.class" />
    			</fileset>
    		</dependency-checker>
    	</target>
    
    
    	<target name="_plain-compile-sources" depends="prepare">
    
    kaloyane's avatar
    kaloyane committed
    		<antcall target="_plain-compile">
    			<param name="src" value="${sources}" />
    		</antcall>
    	</target>
    
    kaloyane's avatar
    kaloyane committed
    	<target name="_plain-compile-tests">
    		<antcall target="_plain-compile">
    
    kaloyane's avatar
    kaloyane committed
    			<param name="src" value="${sources.test}" />
    
    kaloyane's avatar
    kaloyane committed
    		</antcall>
    	</target>
    
    	<!--
    
    ribeaudc's avatar
    ribeaudc committed
          // Compile Java classes using the Eclipse compiler 
          // Note: THIS IS A PRIVATE TARGET. It isn't intended to be used in other build scripts.
          // Parameter: src = source folder
          -->
    
    kaloyane's avatar
    kaloyane committed
    	<target name="_plain-compile">
    		<echo level="info">Compile all classes in ${basedir}/${src} and subfolders</echo>
    		<javac srcdir="${src}"
    		       destdir="${classes}"
    		       classpath="${ecp}"
    
    		       source="1.6"
    		       target="1.6"
    
    kaloyane's avatar
    kaloyane committed
    		       debug="true">
    			<compilerarg line="-warn:none" />
    		</javac>
    		<copy todir="${classes}">
    			<fileset dir="${src}">
    				<include name="**/*.xml" />
    				<include name="**/*.xsd" />
    				<include name="**/*.properties" />
    				<include name="**/*.jpg" />
    				<include name="**/*.png" />
    				<include name="**/*.gif" />
    			</fileset>
    		</copy>
    	</target>
    
    	<!--
    
    ribeaudc's avatar
    ribeaudc committed
          // Runs a TestNG test suite
          // Parameter: test.suite = path of test suite relative to the test source folder
          -->
    
    kaloyane's avatar
    kaloyane committed
    	<target name="_run-testng">
    
    
    		<condition property="log.configuration.file.jvmarg" value="-Dlog4j.configuration=file:${log.configuration.file}">
    			<available file="${log.configuration.file}" />
    		</condition>
    
    		<condition property="log.configuration.file.jvmarg" value="-Dlog4j.dummy.property">
    			<not>
    				<available file="${log.configuration.file}" />
    			</not>
    		</condition>
    
    
    kaloyane's avatar
    kaloyane committed
    		<testng classpath="${ecp}"
    
    				workingDir="."
    				outputdir="${output.test}"
    				failureproperty="${failure.property}">
    
    kaloyane's avatar
    kaloyane committed
    			<xmlfileset dir="${sources.test}" includes="${test.suite}" />
    			<jvmarg value="-Xmx1024M" />
    			<jvmarg value="-XX:MaxPermSize=512m" />
    
    			<jvmarg value="-Dant.project.name=${ant.project.name}" />
    
    			<jvmarg value="-Dlog4j.debug" />
    
    anttil's avatar
    anttil committed
    			<jvmarg value='-Duser.timezone="Europe/Zurich"' />			
    
    			<jvmarg value="${log.configuration.file.jvmarg}" />
    
    kaloyane's avatar
    kaloyane committed
    		</testng>
    
    kaloyane's avatar
    kaloyane committed
    	</target>
    	
    
    kaloyane's avatar
    kaloyane committed
    	<target name="run-tests" depends="compile-tests">
    		<delete dir="${output.test}" />
    
    kaloyane's avatar
    kaloyane committed
    		
    		<antcall target="_run-testng">
    			<param name="test.suite" value="${test.suite}" />
    			<param name="failure.property" value="tests.failed" />
    		</antcall>
    				
    
    kaloyane's avatar
    kaloyane committed
    		<junitreport todir="${output.test}">
    			<fileset dir="${output.test}">
    
    				<include name="junitreports/*.xml" />
    
    kaloyane's avatar
    kaloyane committed
    			</fileset>
    			<report format="noframes" todir="${output.test}" />
    		</junitreport>
    		<fail if="tests.failed" message="At least one test failed." />
    	</target>
    
    	<target name="ci">
    		<antcall target="run-tests">
    			<param name="test.suite" value="tests.xml" />
    		</antcall>
    		<antcall target="check-restrictions" />
    	</target>
    
    felmer's avatar
    felmer committed
      
      <!-- 
         1. Compiles productive and test code
         2. Checks restrictions (@Friend-@Private annotations)
         3. Checks dependencies (defined in /dependency-structure.ddf)
      -->
    
      <target name="compile-and-check" depends="check-dependencies, check-restrictions"/>
    
    kaloyane's avatar
    kaloyane committed
    
    	<target name="check-restrictions" depends="compile, compile-tests">
    
    		<exec executable="sh" failonerror="true">
    
    kaloyane's avatar
    kaloyane committed
    			<arg value="../libraries/restrictionchecker/jrc" />
    			<arg value="-r" />
    			<arg value="../${mainfolder}/${classes}" />
    
    			<!--arg value="-jd" />
    			<arg value="../libraries" /-->
    
    kaloyane's avatar
    kaloyane committed
    			<arg value="-cp" />
    			<arg value="${ecp}" />
    
    kaloyane's avatar
    kaloyane committed
    	</target>
    
    
    cramakri's avatar
    cramakri committed
    	<!-- = = = = = = = = = = = = = = = = =
              macrodef: concat-checksums   
              Take checksum files located in the ${dist} directory, concatenate
              them into one file and delete the individual files.     
             = = = = = = = = = = = = = = = = = -->
    
    kaloyane's avatar
    kaloyane committed
    	<macrodef name="concat-checksums">
    		<sequential>
    			<concat destfile="${checksum.file}">
    				<!-- If a configuration.MD5 file is already in the directory, ignore it -->
    
    felmer's avatar
    felmer committed
    				<fileset dir="${dist}" excludes="${checksum.file.name}">
    					<include name="**/*.MD5"/>
    				</fileset>
    
    kaloyane's avatar
    kaloyane committed
    			</concat>
    			<delete>
    
    felmer's avatar
    felmer committed
    				<fileset dir="${dist}" excludes="${checksum.file.name}">
    					<include name="**/*.MD5"/>
    				</fileset>
    
    kaloyane's avatar
    kaloyane committed
    			</delete>
    		</sequential>
    	</macrodef>
    
    brinn's avatar
    brinn committed
    
    </project>