collector/build.xml
2016-10-28 17:22:44 +02:00

308 lines
12 KiB
XML

<project default="compile" name="CollecTor" basedir=".">
<property name="release.version" value="1.2.0-dev" />
<property name="name" value="CollecTor"/>
<property name="descriptorversion" value="1.5.0" />
<property name="source-and-target-java-version" value="1.7" />
<property name="sources" value="src/main/java"/>
<property name="resources" value="src/main/resources/"/>
<property name="webappsources" value="src/main/webapp"/>
<property name="generated" value="generated"/>
<property name="dist" value="${generated}/dist"/>
<property name="testresult" value="${generated}/test-results"/>
<property name="testsources" value="src/test/java"/>
<property name="testresources" value="src/test/resources/"/>
<property name="coverageresult" value="${generated}/coverage-report/"/>
<property name="instrument" value="${generated}/instrument/"/>
<property name="classes" value="${generated}/classes/"/>
<property name="testclasses" value="${generated}/testclasses/"/>
<property name="docs" value="${generated}/javadoc/"/>
<property name="libs" value="lib"/>
<property name="cobertura.ser.file" value="${basedir}/cobertura.ser" />
<property name="jarfile" value="${dist}/collector-${release.version}.jar" />
<property name="jarsourcesfile" value="${dist}/collector-${release.version}-sources.jar" />
<property name="jarjavadocfile" value="${dist}/collector-${release.version}-javadoc.jar" />
<property name="release.tarball"
value="${dist}/collector-${release.version}.tar.gz" />
<property file="build.properties" />
<patternset id="runtime" >
<include name="commons-codec-1.9.jar"/>
<include name="commons-compress-1.9.jar"/>
<include name="gson-2.2.4.jar"/>
<include name="xz-1.5.jar"/>
<include name="descriptor-${descriptorversion}.jar"/>
<include name="logback-core-1.1.2.jar" />
<include name="logback-classic-1.1.2.jar" />
<include name="slf4j-api-1.7.7.jar" />
</patternset>
<path id="classpath">
<pathelement path="${classes}"/>
<fileset dir="${libs}">
<patternset refid="runtime" />
</fileset>
</path>
<path id="checkstyle.classpath" >
<fileset dir="${libs}">
<include name="checkstyle-6.17-all.jar" />
</fileset>
</path>
<path id="cobertura.classpath">
<fileset dir="${libs}">
<include name="descriptor-${descriptorversion}.jar"/>
<include name="cobertura-2.1.1.jar" />
<include name="slf4j-api-1.7.7.jar" />
<include name="commons-lang3-3.3.2.jar" />
<include name="asm4-5.0.3.jar" />
<include name="asm4-util-5.0.3.jar" />
<include name="asm4-tree-5.0.3.jar" />
<include name="asm4-commons-5.0.3.jar" />
<include name="asm4-analysis-5.0.3.jar" />
<include name="oro-2.0.8.jar" />
<include name="logback-core-1.1.2.jar" />
<include name="logback-classic-1.1.2.jar" />
</fileset>
</path>
<path id="cobertura.test.classpath">
<path location="${instrument}" />
<path refid="test.classpath" />
<path refid="cobertura.classpath" />
</path>
<path id="test.classpath">
<pathelement path="${classes}"/>
<pathelement path="${testclasses}"/>
<pathelement path="${resources}"/>
<pathelement path="${testresources}"/>
<fileset dir="${libs}">
<patternset refid="runtime" />
</fileset>
<fileset dir="${libs}">
<include name="junit4-4.11.jar"/>
<include name="hamcrest-all-1.3.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${classes}"/>
<mkdir dir="${testclasses}"/>
<mkdir dir="${docs}"/>
<mkdir dir="${testresult}"/>
<mkdir dir="${instrument}"/>
</target>
<target name="clean">
<delete includeEmptyDirs="true" quiet="true">
<fileset dir="${generated}" defaultexcludes="false" includes="**" />
</delete>
<delete file="${cobertura.ser.file}" quiet="true"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${sources}"
destdir="${classes}"
source="${source-and-target-java-version}"
target="${source-and-target-java-version}"
debug="true" debuglevel="lines,source"
deprecation="true"
optimize="false"
failonerror="true"
includeantruntime="false">
<classpath refid="classpath"/>
</javac>
</target>
<target name="compile-tests" depends="compile">
<javac destdir="${testclasses}"
srcdir="${testsources}"
source="${source-and-target-java-version}"
target="${source-and-target-java-version}"
debug="true" debuglevel="lines,source"
deprecation="true"
optimize="false"
failonerror="true"
includeantruntime="false">
<classpath refid="classpath"/>
<classpath refid="test.classpath"/>
</javac>
</target>
<target name="docs">
<mkdir dir="${docs}"/>
<javadoc destdir="${docs}"
footer="&amp;copy; 2016 The Tor Project"
doctitle="CollecTor Documentation"
use="true"
windowtitle="CollecTor Documentation">
<classpath refid="classpath"/>
<fileset dir="${sources}/" includes="**/*.java" />
</javadoc>
</target>
<target name="jar" depends="compile,docs">
<exec executable="git" outputproperty="git.revision">
<arg value="rev-parse" />
<arg value="--short" />
<arg value="HEAD" />
</exec>
<jar destfile="${jarfile}"
basedir="${classes}">
<fileset dir="${resources}" >
<include name="collector.properties"/>
<include name="logback.xml"/>
</fileset>
<restrict>
<not>
<name name="META-INF/*" />
</not>
<archives>
<zips>
<fileset dir="${libs}">
<patternset refid="runtime" />
</fileset>
</zips>
</archives>
</restrict>
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="${name}"/>
<attribute name="Implementation-Version"
value="${release.version}-${git.revision}"/>
<attribute name="Main-Class"
value="org.torproject.collector.Main" />
</manifest>
</jar>
<jar destfile="${jarsourcesfile}">
<fileset dir="${sources}" />
<fileset dir="${testsources}" />
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="${name}"/>
<attribute name="Implementation-Version"
value="${release.version}-${git.revision}"/>
</manifest>
</jar>
<jar destfile="${jarjavadocfile}">
<fileset dir="${docs}" />
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="${name}"/>
<attribute name="Implementation-Version"
value="${release.version}-${git.revision}"/>
</manifest>
</jar>
</target>
<target name="signjar" depends="jar">
<signjar alias="${jarsigner.alias}"
storepass="${jarsigner.storepass}"
sigalg="SHA256withRSA"
digestalg="SHA-256"
tsaurl="http://timestamp.digicert.com">
<path>
<pathelement path="${jarfile}"/>
<pathelement path="${jarsourcesfile}"/>
<pathelement path="${jarjavadocfile}"/>
</path>
</signjar>
</target>
<target name="tar" depends="signjar">
<tar destfile="${release.tarball}" compression="gzip">
<tarfileset dir="." prefix="collector-${release.version}">
<include name="${jarfile}" />
<include name="${jarsourcesfile}" />
<include name="${jarjavadocfile}" />
<include name="build.xml" />
<include name="LICENSE" />
<include name="CERT" />
<include name="*.md" />
</tarfileset>
<tarfileset dir="${sources}"
prefix="collector-${release.version}/${sources}" />
<tarfileset dir="${resources}"
prefix="collector-${release.version}/${resources}" />
<tarfileset dir="${webappsources}"
prefix="collector-${release.version}/${webappsources}" />
<tarfileset dir="${testsources}"
prefix="collector-${release.version}/${testsources}" />
<tarfileset dir="${testresources}"
prefix="collector-${release.version}/${testresources}" />
<tarfileset dir="${libs}"
prefix="collector-${release.version}/${libs}" />
</tar>
</target>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
<classpath refid="checkstyle.classpath" />
</taskdef>
<target name="checks" depends="compile,compile-tests">
<checkstyle config="${testresources}/metrics_checks.xml">
<fileset dir="${testsources}"
includes="**/*.java" />
<fileset dir="${sources}"
includes="**/*.java" />
<classpath>
<path refid="classpath" />
<path refid="checkstyle.classpath" />
</classpath>
<formatter type="plain"
toFile="${generated}/checkstyle_report.txt"/>
</checkstyle>
<exec executable="cat" outputproperty="checkstyle.result">
<arg value="${generated}/checkstyle_report.txt" />
</exec>
<fail message="Checkstyle complaints: ${checkstyle.result}" >
<condition>
<not>
<length string="${checkstyle.result}"
length="29" />
</not>
</condition>
</fail>
</target>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<target name="coverage" depends="compile,compile-tests">
<copy todir="${instrument}" >
<fileset dir="${classes}" >
<include name="**/*"/>
</fileset>
</copy>
<cobertura-instrument ignoreTrivial="true">
<fileset dir="${instrument}">
<include name="**/**/*.class" />
</fileset>
</cobertura-instrument>
<junit fork="true" haltonfailure="false" printsummary="on">
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.ser.file}" />
<!-- The following jvmargs prevent test access to the network. -->
<jvmarg value="-Djava.security.policy=${testresources}/junittest.policy"/>
<jvmarg value="-Djava.security.manager"/>
<jvmarg value="-DLOGBASE=${generated}/testcoverage-logs"/>
<classpath refid="cobertura.test.classpath" />
<formatter type="xml" />
<batchtest toDir="${testresult}" >
<fileset dir="${testclasses}" includes="**/*Test.class" />
</batchtest>
</junit>
<cobertura-report format="html" destdir="${coverageresult}" >
<fileset dir="${sources}">
<include name="**/*.java" />
</fileset>
</cobertura-report>
<cobertura-check totallinerate="31" totalbranchrate="26" >
<regex pattern="org.torproject.collector.bridgedescs"
branchrate="87" linerate="73"/>
<regex pattern="org.torproject.collector.conf"
branchrate="87" linerate="100"/>
<regex pattern="org.torproject.collector.cron"
branchrate="66" linerate="72" />
<regex pattern="org.torproject.collector.Main"
branchrate="100" linerate="91" />
</cobertura-check>
</target>
<target name="test" depends="compile,compile-tests">
<junit fork="true" haltonfailure="true" printsummary="off">
<!-- The following two jvmargs prevent test access to the network. -->
<jvmarg value="-Djava.security.policy=${testresources}/junittest.policy"/>
<jvmarg value="-Djava.security.manager"/>
<jvmarg value="-DLOGBASE=${generated}/test-logs"/>
<classpath refid="test.classpath"/>
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="${testclasses}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
</project>