source: router/java/build.xml @ f390831

Last change on this file since f390831 was 91007735, checked in by str4d <str4d@…>, 4 years ago

Update tests to use ScalaTest? 3.0.1

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