metrics-lib/build.xml

302 lines
11 KiB
XML

<project default="jar" name="descriptor" basedir=".">
<property name="release.version" value="1.5.0-dev" />
<property name="allsources" value="src"/>
<property name="sources" value="src/main/java"/>
<property name="resources" value="src/main/resources"/>
<property name="generated" value="generated"/>
<property name="dist" value="${generated}/dist"/>
<property name="classes" value="${generated}/classes"/>
<property name="docs" value="${generated}/javadoc"/>
<property name="tests" value="src/test/java"/>
<property name="testresources" value="src/test/resources/"/>
<property name="testresult" value="${generated}/test-results"/>
<property name="coverageresult" value="${generated}/coverage-report/"/>
<property name="instrument" value="${generated}/instrument/"/>
<property name="testclasses" value="${generated}/testclasses/"/>
<property name="libs" value="lib"/>
<property name="cobertura.ser.file" value="${basedir}/cobertura.ser" />
<property name="jarfile" value="${dist}/descriptor-${release.version}.jar" />
<property name="jarsourcesfile"
value="${dist}/descriptor-${release.version}-sources.jar" />
<property name="jardocsfile"
value="${dist}/descriptor-${release.version}-javadoc.jar" />
<property name="source-and-target-java-version" value="1.7" />
<property name="release.tarball"
value="${dist}/descriptor-${release.version}.tar.gz" />
<property file="build.properties" />
<patternset id="runtime" >
<include name="commons-compress-1.9.jar"/>
<include name="gson-2.2.4.jar"/>
<include name="slf4j-api-1.7.7.jar" />
<include name="xz-1.5.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="test.classpath">
<pathelement path="${classes}"/>
<pathelement path="${testclasses}"/>
<pathelement path="${testresources}"/>
<fileset dir="${libs}">
<patternset refid="runtime" />
</fileset>
<fileset dir="${libs}">
<include name="junit4-4.11.jar"/>
<include name="hamcrest-core-1.3.jar"/>
<include name="logback-core-1.1.2.jar" />
<include name="logback-classic-1.1.2.jar" />
</fileset>
</path>
<path id="cobertura.classpath">
<fileset dir="${libs}">
<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>
<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="init">
<mkdir dir="${classes}"/>
<mkdir dir="${testclasses}"/>
<mkdir dir="${docs}"/>
<mkdir dir="${testresult}"/>
<mkdir dir="${instrument}"/>
</target>
<target name="compile"
depends="init">
<javac destdir="${classes}"
srcdir="${sources}"
source="${source-and-target-java-version}"
target="${source-and-target-java-version}"
debug="true"
deprecation="true"
optimize="false"
failonerror="true"
includeantruntime="false">
<classpath refid="classpath"/>
</javac>
</target>
<target name="docs">
<javadoc destdir="${docs}"
footer="&amp;copy; 2016 The Tor Project"
doctitle="DescripTor API Documentation"
overview="${basedir}/${resources}/overview.html"
use="true"
windowtitle="DescripTor API Documentation">
<classpath refid="classpath"/>
<fileset dir="${sources}">
<exclude name="**/impl/**"/>
</fileset>
</javadoc>
</target>
<target name="testcompile" depends="init">
<javac destdir="${testclasses}"
srcdir="${tests}"
source="${source-and-target-java-version}"
target="${source-and-target-java-version}"
debug="true"
deprecation="true"
optimize="false"
failonerror="true"
includeantruntime="false">
<classpath refid="test.classpath"/>
</javac>
</target>
<target name="test" depends="compile,testcompile">
<junit fork="true" haltonfailure="true" printsummary="off">
<classpath refid="test.classpath"/>
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="${testclasses}"
includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
<target name="benchmark" depends="compile,testcompile">
<java fork="true"
maxmemory="2048m"
classname="org.torproject.descriptor.benchmark.MeasurePerformance">
<classpath refid="classpath"/>
</java>
</target>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
<classpath refid="checkstyle.classpath" />
</taskdef>
<target name="checks" depends="compile">
<checkstyle config="${testresources}/metrics_checks.xml">
<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>
<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}">
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="DescripTor"/>
<attribute name="Implementation-Version"
value="${release.version}-${git.revision}"/>
</manifest>
</jar>
<jar destfile="${jarsourcesfile}">
<fileset dir="${sources}" />
<fileset dir="${tests}"/>
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="DescripTor"/>
<attribute name="Implementation-Version"
value="${release.version}-${git.revision}"/>
</manifest>
</jar>
<jar destfile="${jardocsfile}">
<fileset dir="${docs}" />
<manifest>
<attribute name="Created-By" value="The Tor Project" />
<attribute name="Implementation-Title" value="DescripTor"/>
<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"
lazy="true">
<path>
<fileset dir="${dist}" includes="descriptor-${release.version}*.jar" />
</path>
</signjar>
</target>
<target name="tar" depends="signjar">
<tar destfile="${release.tarball}" compression="gzip">
<tarfileset dir="." prefix="descriptor-${release.version}">
<include name="${jarfile}" />
<include name="${jarsourcesfile}" />
<include name="${jardocsfile}" />
<include name="build.xml" />
<include name="LICENSE" />
<include name="CERT" />
<include name="*.md" />
</tarfileset>
<tarfileset dir="${allsources}"
prefix="descriptor-${release.version}/${allsources}" />
<tarfileset dir="${libs}"
prefix="descriptor-${release.version}/${libs}" />
</tar>
</target>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<target name="coverage" depends="compile,testcompile">
<delete file="${cobertura.ser.file}" quiet="true" />
<copy todir="${instrument}" >
<fileset dir="${classes}"/>
</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}" />
<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="58" totalbranchrate="50" >
<regex pattern="org.torproject.descriptor.benchmark.*"
linerate="0" branchrate="0"/>
<regex pattern="org.torproject.descriptor.index"
linerate="97" branchrate="62"/>
<regex pattern="org.torproject.descriptor.DescriptorSourceFactory"
linerate="100" branchrate="77"/>
<regex pattern="org.torproject.descriptor.index.DescriptorIndexCollector"
linerate="92" branchrate="61"/>
<regex pattern="org.torproject.descriptor.index.IndexNode"
linerate="100" branchrate="61"/>
<regex pattern="org.torproject.descriptor.index.FileNode"
linerate="100" branchrate="100"/>
<regex pattern="org.torproject.descriptor.index.DirectoryNode"
linerate="100" branchrate="100"/>
</cobertura-check>
</target>
</project>