source: router/java/build.xml @ 0a99784

Last change on this file since 0a99784 was 0a99784, checked in by zzz <zzz@…>, 21 months ago

Build: Add javac.classpath to junit.compileTest targets (ticket #2333)

  • Property mode set to 100644
File size: 16.3 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                <pathelement location="../../core/java/build/gnu-getopt.jar" />
20                <pathelement location="../../core/java/build/httpclient.jar" />
21                <pathelement location="../../core/java/build/httpcore.jar" />
22            </classpath>
23        </depend>
24    </target>
25    <target name="dependVersion">
26        <!-- Force the dependency on the RouterVersion as depend doesn't recognize constant changes  -->
27        <dependset>
28             <srcfilelist dir="." files="build/obj/net/i2p/router/RouterVersion.class" />
29             <targetfilelist dir="." files="build/obj/net/i2p/router/Router.class" />
30             <targetfilelist dir="." files="build/obj/net/i2p/router/StatisticsManager.class" />
31        </dependset>
32    </target>
33
34    <!-- only used if not set by a higher build.xml -->
35    <property name="javac.compilerargs" value="" />
36    <property name="javac.version" value="1.7" />
37    <property name="manifest.classpath.name" value="Class-Path" />
38
39    <target name="compile" depends="depend, dependVersion">
40        <mkdir dir="./build" />
41        <mkdir dir="./build/obj" />
42        <javac srcdir="./src" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
43               debuglevel="lines,vars,source"
44               includeAntRuntime="false"
45               destdir="./build/obj" classpath="../../core/java/build/obj:../../core/java/build/i2p.jar:../../core/java/build/gnu-getopt.jar:../../core/java/build/httpclient.jar:../../core/java/build/httpcore.jar" >
46            <compilerarg line="${javac.compilerargs}" />
47        </javac>
48    </target>
49
50    <target name="listChangedFiles" if="mtn.available" >
51        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
52            <arg value="list" />
53            <arg value="changed" />
54            <arg value="." />
55        </exec>
56        <!-- \n in an attribute value generates an invalid manifest -->
57        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
58            <arg value="-s" />
59            <arg value="[:space:]" />
60            <arg value="," />
61        </exec>
62    </target>
63
64    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
65        <!-- set if unset -->
66        <property name="workspace.changes.tr" value="" />
67        <jar destfile="./build/router.jar" basedir="./build/obj" includes="**/*.class" >
68            <manifest>
69                <!-- so people with very old wrapper.config files will still work with Jetty 6 -->
70                <attribute name="${manifest.classpath.name}" value="i2p.jar addressbook.jar jetty-i2p.jar jetty-rewrite-handler.jar jetty-start.jar jetty-util.jar" />
71                <attribute name="Specification-Title" value="I2P Router" />
72                <attribute name="Specification-Version" value="${release.number}" />
73                <attribute name="Specification-Vendor" value="The I2P Project https://geti2p.net/" />
74                <attribute name="Implementation-Title" value="I2P Java Router" />
75                <attribute name="Implementation-Version" value="${full.version}" />
76                <attribute name="Implementation-Vendor" value="The I2P Project https://geti2p.net/" />
77                <attribute name="Built-By" value="${build.built-by}" />
78                <attribute name="Build-Date" value="${build.timestamp}" />
79                <attribute name="Base-Revision" value="${workspace.version}" />
80                <attribute name="Main-Class" value="net.i2p.router.CommandLine" />
81                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
82                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
83                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
84            </manifest>
85        </jar>
86    </target>
87
88    <target name="jarUpToDate">
89        <uptodate property="jar.uptodate" targetfile="build/router.jar" >
90            <srcfiles dir= "." includes="build/obj/**/*.class" />
91        </uptodate>
92    </target>
93
94    <target name="javadoc">
95        <mkdir dir="./build" />
96        <mkdir dir="./build/javadoc" />
97        <javadoc 
98            sourcepath="./src:./test/junit:../../core/java/src:../../core/java/test/junit" destdir="./build/javadoc" 
99            packagenames="*" 
100            use="true" 
101            splitindex="true" 
102            windowtitle="I2P Router" />
103    </target>
104
105    <!-- for Maven Central -->
106    <target name="javadocJar" depends="javadoc">
107        <jar jarfile="./build/router-${release.number}-javadoc.jar">
108            <fileset dir="./build/javadoc" />
109        </jar>
110    </target>
111    <target name="sourcesJar">
112        <jar jarfile="./build/router-${release.number}-sources.jar">
113            <fileset dir="./src" />
114        </jar>
115    </target>
116
117    <!-- scala paths -->
118    <target name="scala.init">
119        <property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
120        <property name="scala-xml.jar" value="${scalatest.libs}/scala-xml.jar" />
121        <property name="scalactic.jar" value="${scalatest.libs}/scalactic.jar" />
122        <property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
123        <taskdef resource="scala/tools/ant/antlib.xml">
124            <classpath>
125                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
126                <pathelement location="${scalatest.libs}/scala-reflect.jar" />
127                <pathelement location="${scala-library.jar}" />
128            </classpath>
129        </taskdef>
130    </target>
131
132    <!-- unit tests -->
133    <target name="builddepscalatest">
134        <ant dir="../../core/java/" target="jar" />
135        <ant dir="../../core/java/" target="jarScalaTest" />
136    </target>
137    <target name="builddeptest">
138        <ant dir="../../core/java/" target="jarTest" />
139    </target>
140    <target name="scalatest.compileTest" depends="builddepscalatest, compile, scala.init">
141        <mkdir dir="./build" />
142        <mkdir dir="./build/obj_scala" />
143        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
144            <classpath>
145                <pathelement location="${javac.classpath}" />
146                <pathelement location="${scala-library.jar}" />
147                <pathelement location="${scalactic.jar}" />
148                <pathelement location="${scalatest.jar}" />
149                <pathelement location="../../core/java/build/i2pscalatest.jar" />
150                <pathelement location="./build/obj" />
151            </classpath>
152        </scalac>
153    </target>
154
155    <target name="junit.compileTest" depends="builddeptest, compile">
156        <mkdir dir="./build" />
157        <mkdir dir="./build/obj" />
158        <!-- set hamcrest and junit homes to the old default unless overridden elsewhere -->
159        <property name="hamcrest.home" value="${ant.home}/lib/" />
160        <property name="junit.home" value="${ant.home}/lib/" />
161        <javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
162            debuglevel="lines,vars,source"
163            includeAntRuntime="true"
164            destdir="./build/obj">
165            <classpath>
166                <pathelement location="${javac.classpath}" />
167                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
168                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
169                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
170                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
171                <pathelement location="${junit.home}/junit4.jar" />
172                <pathelement location="../../core/java/build/i2ptest.jar" />
173            </classpath>
174            <compilerarg line="${javac.compilerargs}" />
175        </javac>
176    </target>
177    <!-- jars with tests -->
178    <target name="jarScalaTest" depends="scalatest.compileTest">
179        <mkdir dir="./build/obj_scala_jar" />
180        <copy todir="./build/obj_scala_jar">
181            <fileset dir="./build/">
182                <include name="obj/**/*.class"/>
183            </fileset>
184            <mapper type="glob" from="obj/*" to="*" />
185        </copy>
186        <copy todir="./build/obj_scala_jar">
187            <fileset dir="./build/">
188                <include name="obj_scala/**/*.class"/>
189            </fileset>
190            <mapper type="glob" from="obj_scala/*" to="*" />
191        </copy>
192        <jar destfile="./build/routerscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" />
193    </target>
194    <target name="jarTest" depends="junit.compileTest">
195        <jar destfile="./build/routertest.jar" basedir="./build/obj" includes="**/*.class" />
196    </target>
197    <!-- preparation of code coverage tool of choice -->
198    <target name="prepareClover" depends="compile" if="with.clover">
199        <taskdef resource="clovertasks"/>
200        <mkdir dir="../../reports/router/clover" />
201        <clover-setup initString="../../reports/router/clover/coverage.db"/>
202    </target>
203    <target name="prepareCobertura" depends="compile" if="with.cobertura">
204        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
205        <mkdir dir="./build/obj_cobertura" />
206        <delete file="./cobertura.ser" />
207        <cobertura-instrument todir="./build/obj_cobertura">
208            <fileset dir="./build/obj">
209                <include name="**/*.class"/>
210                <!-- exclude Test classes -->
211                <exclude name="**/*Test.class" />
212                <!-- exclude anything not in net.i2p.* -->
213                <exclude name="org/cybergarage/**/*.class" />
214                <exclude name="org/freenetproject/**/*.class" />
215                <exclude name="org/xlattice/**/*.class" />
216            </fileset>
217        </cobertura-instrument>
218    </target>
219    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
220    <!-- end preparation of code coverage tool -->
221    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
222        <mkdir dir="../../reports/router/scalatest/" />
223        <delete>
224            <fileset dir="../../reports/router/scalatest">
225                <include name="TEST-*.xml"/>
226            </fileset>
227        </delete>
228        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
229            <classpath>
230                <pathelement location="${scala-library.jar}" />
231                <pathelement location="${scala-xml.jar}" />
232                <pathelement location="${scalactic.jar}" />
233                <pathelement location="${scalatest.jar}" />
234                <pathelement location="./build/obj_cobertura" />
235                <pathelement location="./build/obj" />
236                <pathelement location="../../core/java/build/i2p.jar" />
237                <pathelement location="../../build/jbigi.jar" />
238                <pathelement location="${with.clover}" />
239                <pathelement location="${with.cobertura}" />
240            </classpath>
241        </taskdef>
242        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
243            <tagsToExclude>
244                SlowTests
245            </tagsToExclude>
246            <reporter type="stdout" />
247            <reporter type="junitxml" directory="../../reports/router/scalatest/" />
248        </scalatest>
249        <!-- set if unset -->
250        <property name="host.fakename" value="i2ptester" />
251        <!-- replace hostname that junit inserts into reports with fake one -->
252        <replaceregexp byline="true"
253            match="(hostname=)&quot;[^&quot;]+&quot;"
254            replace="\1&quot;${host.fakename}&quot;">
255            <fileset dir="../../reports/router/scalatest/" />
256        </replaceregexp>
257    </target>
258    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
259        <mkdir dir="../../reports/router/junit/" />
260        <delete>
261            <fileset dir="../../reports/router/junit">
262                <include name="TEST-*.xml"/>
263            </fileset>
264        </delete>
265        <junit printsummary="withOutAndErr" fork="yes" showoutput="yes" >
266            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
267            <classpath>
268                <pathelement path="${javac.classpath}" />
269                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
270                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
271                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
272                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
273                <pathelement location="${junit.home}/junit4.jar" />
274                <pathelement location="./build/obj_cobertura" />
275                <pathelement location="./build/obj" />
276                <pathelement location="../../core/java/build/i2ptest.jar" />
277                <pathelement location="../../build/jbigi.jar" />
278                <pathelement location="${with.clover}" />
279                <pathelement location="${with.cobertura}" />
280            </classpath>
281            <batchtest todir="../../reports/router/junit/">
282                <fileset dir="./test/junit">
283                    <include name="**/*Test.java" />
284                    <include name="**/*IT.java" if="runIntegrationTests" />
285                </fileset>
286            </batchtest>
287            <formatter type="xml"/>
288        </junit>
289        <!-- set if unset -->
290        <property name="host.fakename" value="i2ptester" />
291        <!-- replace hostname that junit inserts into reports with fake one -->
292        <replaceregexp byline="true"
293            match="(hostname=)&quot;[^&quot;]+&quot;"
294            replace="\1&quot;${host.fakename}&quot;">
295            <fileset dir="../../reports/router/junit/" />
296        </replaceregexp>
297    </target>
298
299    <!-- both junit and scala, but we have no scala tests yet -->
300    <target name="test" depends="junit.test"/>
301
302    <!-- test reports -->
303    <target name="scalatest.report">
304        <junitreport todir="../../reports/router/scalatest">
305            <fileset dir="../../reports/router/scalatest">
306                <include name="TEST-*.xml"/>
307            </fileset>
308            <report format="frames" todir="../../reports/router/html/scalatest"/>
309        </junitreport>
310    </target>
311    <target name="junit.report">
312        <junitreport todir="../../reports/router/junit">
313            <fileset dir="../../reports/router/junit">
314                <include name="TEST-*.xml"/>
315            </fileset>
316            <report format="frames" todir="../../reports/router/html/junit"/>
317        </junitreport>
318    </target>
319    <target name="clover.report" depends="test" if="with.clover">
320        <clover-report>
321            <current outfile="../../reports/router/html/clover">
322                <format type="html"/>
323            </current>
324        </clover-report>
325    </target>
326    <target name="cobertura.report" depends="test" if="with.cobertura">
327        <mkdir dir="../../reports/router/cobertura" />
328        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/router/cobertura" />
329        <mkdir dir="../../reports/router/html/cobertura" />
330        <cobertura-report format="html" srcdir="./src" destdir="../../reports/router/html/cobertura" />
331        <delete file="./cobertura.ser" />
332    </target>
333    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
334    <!-- end test reports -->
335    <target name="fulltest" depends="cleandep, test, test.report" />
336    <!-- end unit tests -->
337
338    <target name="clean">
339        <delete dir="./build" />
340    </target>
341    <target name="cleandep" depends="clean">
342    </target>
343    <target name="distclean" depends="clean">
344    </target>
345</project>
Note: See TracBrowser for help on using the repository browser.