source: router/java/build.xml @ 6a26c0b

Last change on this file since 6a26c0b was 6a26c0b, checked in by str4d <str4d@…>, 8 years ago

Edited router build.xml to match core build.xml (inc. clover, cobertura stuff)

  • Property mode set to 100644
File size: 7.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="i2p_router">
3    <target name="all" depends="clean, build" />
4    <target name="build" depends="builddep, jar" />
5    <target name="builddep">
6        <!-- run from top level build.xml to get dependencies built -->
7    </target>
8    <condition property="depend.available">
9        <typefound name="depend" />
10    </condition>
11    <target name="depend" if="depend.available">
12        <depend
13            cache="../../build"
14            srcdir="./src" 
15            destdir="./build/obj" >
16            <!-- Depend on classes instead of jars where available -->
17            <classpath>
18                <pathelement location="../../core/java/build/obj" />
19            </classpath>
20        </depend>
21    </target>
22    <target name="dependVersion">
23        <!-- Force the dependency on the RouterVersion as depend doesn't recognize constant changes  -->
24        <dependset>
25             <srcfilelist dir="." files="build/obj/net/i2p/router/RouterVersion.class" />
26             <targetfilelist dir="." files="build/obj/net/i2p/router/Router.class" />
27             <targetfilelist dir="." files="build/obj/net/i2p/router/StatisticsManager.class" />
28        </dependset>
29    </target>
30    <!-- only used if not set by a higher build.xml -->
31    <property name="javac.compilerargs" value="" />
32    <target name="compile" depends="depend, dependVersion">
33        <mkdir dir="./build" />
34        <mkdir dir="./build/obj" />
35        <javac srcdir="./src" debug="true" source="1.5" target="1.5" deprecation="on"
36               includeAntRuntime="false"
37               destdir="./build/obj" classpath="../../core/java/build/i2p.jar" >
38            <compilerarg line="${javac.compilerargs}" />
39        </javac>
40    </target>
41
42    <target name="listChangedFiles" if="mtn.available" >
43        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
44            <arg value="list" />
45            <arg value="changed" />
46            <arg value="." />
47        </exec>
48        <!-- \n in an attribute value generates an invalid manifest -->
49        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
50            <arg value="-s" />
51            <arg value="[:space:]" />
52            <arg value="," />
53        </exec>
54    </target>
55
56    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
57        <!-- set if unset -->
58        <property name="workspace.changes.tr" value="" />
59        <jar destfile="./build/router.jar" basedir="./build/obj" includes="**/*.class" >
60            <manifest>
61                <attribute name="Implementation-Version" value="${full.version}" />
62                <attribute name="Build-Date" value="${build.timestamp}" />
63                <attribute name="Base-Revision" value="${workspace.version}" />
64                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
65            </manifest>
66        </jar>
67    </target>
68
69    <target name="jarUpToDate">
70        <uptodate property="jar.uptodate" targetfile="build/router.jar" >
71            <srcfiles dir= "." includes="build/obj/**/*.class" />
72        </uptodate>
73    </target>
74
75    <target name="javadoc">
76        <mkdir dir="./build" />
77        <mkdir dir="./build/javadoc" />
78        <javadoc 
79            sourcepath="./src:./test:../../core/java/src:../../core/java/test" destdir="./build/javadoc" 
80            packagenames="*" 
81            use="true" 
82            splitindex="true" 
83            windowtitle="I2P Router" />
84    </target>
85
86    <!-- unit tests -->
87    <target name="builddeptest">
88        <ant dir="../../core/java/" target="jarTest" />
89    </target>
90    <target name="compileTest" depends="builddeptest">
91        <mkdir dir="./build" />
92        <mkdir dir="./build/obj" />
93        <!-- junit classes are in ant runtime -->
94        <javac srcdir="./src:./test" debug="true" source="1.5" target="1.5" deprecation="on"
95               includeAntRuntime="true"
96               destdir="./build/obj" classpath="../../core/java/build/i2ptest.jar" >
97            <compilerarg line="${javac.compilerargs}" />
98        </javac>
99    </target>
100    <target name="jarTest" depends="compileTest">
101        <jar destfile="./build/routertest.jar" basedir="./build/obj" includes="**/*.class" />
102    </target>
103    <!-- preparation of code coverage tool of choice -->
104    <target name="prepareClover" depends="compileTest" if="with.clover">
105        <taskdef resource="clovertasks"/>
106        <mkdir dir="../../reports/router/clover" />
107        <clover-setup initString="../../reports/router/clover/coverage.db"/>
108    </target>
109    <target name="prepareCobertura" depends="compileTest" if="with.cobertura">
110        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
111        <mkdir dir="./build/obj_cobertura" />
112        <delete file="./cobertura.ser" />
113        <cobertura-instrument todir="./build/obj_cobertura">
114            <fileset dir="./build/obj">
115                <include name="**/*.class"/>
116                <exclude name="**/*Test.class" />
117            </fileset>
118        </cobertura-instrument>
119    </target>
120    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
121    <!-- end preparation of code coverage tool -->
122    <target name="test" depends="compileTest">
123        <mkdir dir="../../reports/router/junit/" />
124        <delete>
125            <fileset dir="../../reports/router/junit">
126                <include name="TEST-*.xml"/>
127            </fileset>
128        </delete>
129        <junit printsummary="on" fork="yes">
130            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
131            <classpath>
132                <pathelement path="${classpath}" />
133                <pathelement location="./build/obj_cobertura" />
134                <pathelement location="./build/obj" />
135                <pathelement location="../../core/java/build/i2ptest.jar" />
136                <pathelement location="../../build/jbigi.jar" />
137                <pathelement location="${with.clover}" />
138                <pathelement location="${with.cobertura}" />
139            </classpath>
140            <batchtest todir="../../reports/router/junit/">
141                <fileset dir="./test/">
142                    <include name="**/*Test.java" />
143                </fileset>
144            </batchtest>
145            <formatter type="xml"/>
146        </junit>
147    </target>
148    <!-- test reports -->
149    <target name="junit.report">
150        <junitreport todir="../../reports/router/junit">
151            <fileset dir="../../reports/router/junit">
152                <include name="TEST-*.xml"/>
153            </fileset>
154            <report format="frames" todir="../../reports/router/html/junit"/>
155        </junitreport>
156    </target>
157    <target name="clover.report" depends="test" if="with.clover">
158        <clover-report>
159            <current outfile="../../reports/router/html/clover">
160                <format type="html"/>
161            </current>
162        </clover-report>
163    </target>
164    <target name="cobertura.report" depends="test" if="with.cobertura">
165        <mkdir dir="../../reports/router/cobertura" />
166        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/router/cobertura" />
167        <mkdir dir="../../reports/router/html/cobertura" />
168        <cobertura-report format="html" srcdir="./src" destdir="../../reports/router/html/cobertura" />
169        <delete file="./cobertura.ser" />
170    </target>
171    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
172    <!-- end test reports -->
173    <target name="fulltest" depends="cleandep, builddeptest, jarTest, test, junit.report" />
174    <!-- end unit tests -->
175
176    <target name="clean">
177        <delete dir="./build" />
178    </target>
179    <target name="cleandep" depends="clean">
180    </target>
181    <target name="distclean" depends="clean">
182    </target>
183</project>
Note: See TracBrowser for help on using the repository browser.