source: core/java/build.xml @ 6e7dedb

Last change on this file since 6e7dedb was 91007735, checked in by str4d <str4d@…>, 5 years ago

Update tests to use ScalaTest? 3.0.1

  • Property mode set to 100644
File size: 18.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="i2p_sdk">
3    <target name="all" depends="clean, build" />
4    <target name="build" depends="builddep, jar" />
5    <target name="builddep">
6        <!-- noop, since the core doesnt depend on anything -->
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>
17    </target>
18
19    <!-- only used if not set by a higher build.xml -->
20    <property name="javac.compilerargs" value="" />
21    <property name="javac.classpath" value="" />
22    <property name="javac.version" value="1.7" />
23
24    <!-- fixups if we're using libintl.jar for GettextResource.java -->
25    <condition property="source.exclude1" value="gnu/gettext/GettextResource.java" else="NOTHING" >
26        <istrue value="${with-gettext-base}" />
27    </condition>
28    <condition property="javac.classpath.mod1" value="build/libintl.jar:" else="" >
29        <istrue value="${with-gettext-base}" />
30    </condition>
31    <!-- fixups if we're using gnu-getopt.jar for gnu/getopt/* -->
32    <condition property="source.exclude2" value="gnu/getopt/**" else="NOTHING" >
33        <istrue value="${with-libgetopt-java}" />
34    </condition>
35    <condition property="javac.classpath.mod2" value="build/gnu-getopt.jar:" else="" >
36        <istrue value="${with-libgetopt-java}" />
37    </condition>
38    <condition property="translation.includes" value="NOTHING" else="gnu/getopt/*.properties" >
39        <istrue value="${with-libgetopt-java}" />
40    </condition>
41    <!-- fixups if we're using httpclient.jar and httpcore.jar for org.apache.http classes -->
42    <condition property="source.exclude3" value="org/apache/http/**" else="NOTHING" >
43        <istrue value="${with-libhttpclient-java}" />
44    </condition>
45    <condition property="javac.classpath.mod3" value="build/httpclient.jar:build/httpcore.jar:" else="" >
46        <istrue value="${with-libhttpclient-java}" />
47    </condition>
48    <property name="javac.classpath.mod" value="${javac.classpath.mod1}${javac.classpath.mod2}${javac.classpath.mod3}${javac.classpath}" />
49
50    <!-- jar classpath fixups -->
51    <condition property="gettext.jar" value="/usr/share/java/libintl.jar" else="" >
52        <istrue value="${with-gettext-base}" />
53    </condition>
54    <condition property="getopt.jar" value="/usr/share/java/gnu-getopt.jar" else="" >
55        <istrue value="${with-libgetopt-java}" />
56    </condition>
57    <condition property="httpclient.jar" value="/usr/share/java/httpclient.jar /usr/share/java/httpcore.jar" else="" >
58        <istrue value="${with-libhttpclient-java}" />
59    </condition>
60
61    <target name="compile" depends="depend">
62        <mkdir dir="./build" />
63        <mkdir dir="./build/obj" />
64        <!-- sourcepath="" necessary for excludes to work, see ant manual for javac -->
65        <javac sourcepath="" srcdir="./src" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
66               debuglevel="lines,vars,source"
67               includeAntRuntime="false"
68               destdir="./build/obj" classpath="${javac.classpath.mod}" >
69            <compilerarg line="${javac.compilerargs}" />
70            <include name="**/*.java" />
71            <exclude name="${source.exclude1}" />
72            <exclude name="${source.exclude2}" />
73            <exclude name="${source.exclude3}" />
74        </javac>
75    </target>
76
77    <target name="listChangedFiles" if="mtn.available" >
78        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
79            <arg value="list" />
80            <arg value="changed" />
81            <arg value="." />
82        </exec>
83        <!-- \n in an attribute value generates an invalid manifest -->
84        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
85            <arg value="-s" />
86            <arg value="[:space:]" />
87            <arg value="," />
88        </exec>
89    </target>
90
91    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
92        <!-- set if unset -->
93        <property name="workspace.changes.tr" value="" />
94        <jar destfile="./build/i2p.jar" >
95            <fileset dir="./build/obj" includes="**/*.class" />
96            <!-- the getopt translation files -->
97            <fileset dir="src" includes="${translation.includes}" />
98            <manifest>
99                <attribute name="Class-Path" value="${gettext.jar} ${getopt.jar} ${httpclient.jar}" />
100                <attribute name="Specification-Title" value="I2P Core API" />
101                <attribute name="Specification-Version" value="${release.number}" />
102                <attribute name="Specification-Vendor" value="The I2P Project https://geti2p.net/" />
103                <attribute name="Implementation-Title" value="I2P Java Core API" />
104                <attribute name="Implementation-Version" value="${full.version}" />
105                <attribute name="Implementation-Vendor" value="The I2P Project https://geti2p.net/" />
106                <attribute name="Built-By" value="${build.built-by}" />
107                <attribute name="Build-Date" value="${build.timestamp}" />
108                <attribute name="Base-Revision" value="${workspace.version}" />
109                <attribute name="Main-Class" value="net.i2p.util.CommandLine" />
110                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
111                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
112                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
113            </manifest>
114        </jar>
115    </target>
116
117    <target name="jarUpToDate" >
118        <uptodate property="jar.uptodate" targetfile="build/i2p.jar" >
119            <srcfiles dir= "build/obj" includes="**/*.class" />
120        </uptodate>
121    </target>
122
123    <target name="javadoc">
124        <mkdir dir="./build" />
125        <mkdir dir="./build/javadoc" />
126        <javadoc sourcepath="./src:./test/junit" destdir="./build/javadoc" packagenames="*" use="true" splitindex="true" windowtitle="I2P SDK" />
127    </target>
128
129    <!-- for Maven Central -->
130    <target name="javadocJar" depends="javadoc">
131        <jar jarfile="./build/i2p-${release.number}-javadoc.jar">
132            <fileset dir="./build/javadoc" />
133        </jar>
134    </target>
135    <target name="sourcesJar">
136        <jar jarfile="./build/i2p-${release.number}-sources.jar">
137            <fileset dir="./src" />
138        </jar>
139    </target>
140
141    <!-- scala paths -->
142    <target name="scala.init">
143        <property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
144        <property name="scala-xml.jar" value="${scalatest.libs}/scala-xml.jar" />
145        <property name="scalactic.jar" value="${scalatest.libs}/scalactic.jar" />
146        <property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
147        <taskdef resource="scala/tools/ant/antlib.xml">
148            <classpath>
149                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
150                <pathelement location="${scalatest.libs}/scala-reflect.jar" />
151                <pathelement location="${scala-library.jar}" />
152            </classpath>
153        </taskdef>
154    </target>
155
156    <!-- unit tests -->
157    <target name="scalatest.compileTest" depends="compile, scala.init">
158        <mkdir dir="./build" />
159        <mkdir dir="./build/obj_scala" />
160        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
161            <classpath>
162                <pathelement location="${javac.classpath.mod}" />
163                <pathelement location="${scala-library.jar}" />
164                <pathelement location="${scalactic.jar}" />
165                <pathelement location="${scalatest.jar}" />
166                <pathelement location="./build/obj" />
167            </classpath>
168        </scalac>
169    </target>
170    <target name="junit.compileTest" depends="compile">
171        <mkdir dir="./build" />
172        <mkdir dir="./build/obj" />
173        <!-- set hamcrest and junit homes to the old default unless overridden elsewhere -->
174        <echo message="[DEBUG] ant home is ${ant.home}" />
175        <echo message="[DEBUG] junit home before override is ${junit.home}" />
176        <echo message="[DEBUG] hamcrest home before override is ${hamcrest.home}" />
177        <property name="hamcrest.home" value="${ant.home}/lib/" />
178        <property name="junit.home" value="${ant.home}/lib/" />
179        <echo message="[DEBUG] junit home after override is ${junit.home}" />
180        <echo message="[DEBUG] hamcrest home after override is ${hamcrest.home}" />
181        <javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
182               debuglevel="lines,vars,source"
183               includeAntRuntime="true"
184               excludes="${source.exclude}"
185               destdir="./build/obj" >
186            <classpath>
187                <pathelement path="${javac.classpath.mod}" />
188                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
189                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
190                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
191                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
192                <pathelement location="${junit.home}/junit4.jar" />
193            </classpath>
194            <compilerarg line="${javac.compilerargs}" />
195        </javac>
196        <!-- EdDSA test vectors -->
197        <copy todir="./build/obj">
198            <fileset dir="./test/junit/">
199                <include name="net/i2p/crypto/eddsa/test.data"/>
200                <include name="net/i2p/crypto/eddsa/math/baseDblPrecmp"/>
201                <include name="net/i2p/crypto/eddsa/math/basePrecmp"/>
202            </fileset>
203        </copy>
204    </target>
205    <!-- jars with tests -->
206    <target name="jarScalaTest" depends="scalatest.compileTest">
207        <mkdir dir="./build/obj_scala_jar" />
208        <copy todir="./build/obj_scala_jar">
209            <fileset dir="./build/">
210                <include name="obj/**/*.class"/>
211            </fileset>
212            <mapper type="glob" from="obj/*" to="*" />
213        </copy>
214        <copy todir="./build/obj_scala_jar">
215            <fileset dir="./build/">
216                <include name="obj_scala/**/*.class"/>
217            </fileset>
218            <mapper type="glob" from="obj_scala/*" to="*" />
219        </copy>
220        <jar destfile="./build/i2pscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" />
221    </target>
222    <target name="jarTest" depends="junit.compileTest">
223        <!-- warning - The junit.test target below doesn't actually include i2ptest.jar in the classpath,
224             only the build/obj directory.
225          -->
226        <jar destfile="./build/i2ptest.jar" basedir="./build/obj" includes="**/*.class **/test.data **/baseDblPrecmp **/basePrecmp" />
227    </target>
228    <!-- preparation of code coverage tool of choice -->
229    <target name="prepareClover" depends="compile" if="with.clover">
230        <taskdef resource="clovertasks"/>
231        <mkdir dir="../../reports/core/clover" />
232        <clover-setup initString="../../reports/core/clover/coverage.db"/>
233    </target>
234    <target name="prepareCobertura" depends="compile" if="with.cobertura">
235        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
236        <mkdir dir="./build/obj_cobertura" />
237        <delete file="./cobertura.ser" />
238        <cobertura-instrument todir="./build/obj_cobertura">
239            <fileset dir="./build/obj">
240                <include name="**/*.class"/>
241                <!-- exclude Test classes -->
242                <exclude name="**/*Test.class" />
243                <exclude name="**/*TestSuite.class" />
244                <!-- specific excludes -->
245                <exclude name="**/AllCoreTests.class" />
246                <exclude name="**/stat/SimpleStatDumper.class" />
247                <exclude name="**/stat/SizeMeasure.class" />
248                <exclude name="**/stat/StatLogSplitter.class" />
249                <!-- exclude anything not in net.i2p.* -->
250                <exclude name="com/nettgryppa/**/*.class" />
251                <exclude name="freenet/**/*.class" />
252                <exclude name="gnu/**/*.class" />
253                <exclude name="net/metanotion/**/*.class" />
254                <exclude name="org/bouncycastle/**/*.class" />
255                <exclude name="org/xlattice/**/*.class" />
256            </fileset>
257        </cobertura-instrument>
258    </target>
259    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
260    <!-- end preparation of code coverage tool -->
261    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
262        <mkdir dir="../../reports/core/scalatest/" />
263        <delete>
264            <fileset dir="../../reports/core/scalatest">
265                <include name="TEST-*.xml"/>
266            </fileset>
267        </delete>
268        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
269            <classpath>
270                <pathelement location="${scala-library.jar}" />
271                <pathelement location="${scala-xml.jar}" />
272                <pathelement location="${scalactic.jar}" />
273                <pathelement location="${scalatest.jar}" />
274                <pathelement location="./build/obj_cobertura" />
275                <pathelement location="./build/obj" />
276                <pathelement location="../../build/jbigi.jar" />
277                <pathelement location="${with.clover}" />
278                <pathelement location="${with.cobertura}" />
279            </classpath>
280        </taskdef>
281        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
282            <tagsToExclude>
283                SlowTests
284            </tagsToExclude>
285            <reporter type="stdout" />
286            <reporter type="junitxml" directory="../../reports/core/scalatest/" />
287        </scalatest>
288        <!-- set if unset -->
289        <property name="host.fakename" value="i2ptester" />
290        <!-- replace hostname that junit inserts into reports with fake one -->
291        <replaceregexp byline="true"
292            match="(hostname=)&quot;[^&quot;]+&quot;"
293            replace="\1&quot;${host.fakename}&quot;">
294            <fileset dir="../../reports/core/scalatest/" />
295        </replaceregexp>
296    </target>
297    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
298        <property name="hamcrest.home" value="${ant.home}/lib/" />
299        <property name="junit.home" value="${ant.home}/lib/" />
300        <mkdir dir="../../reports/core/junit/" />
301        <delete>
302            <fileset dir="../../reports/core/junit">
303                <include name="TEST-*.xml"/>
304            </fileset>
305        </delete>
306        <junit printsummary="withOutAndErr" fork="yes" maxmemory="384m" showoutput="yes" >
307            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
308            <classpath>
309                <pathelement location="../../installer/resources/" />
310                <pathelement path="${javac.classpath.mod}" />
311                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
312                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
313                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
314                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
315                <pathelement location="${junit.home}/junit4.jar" />
316                <pathelement location="./build/obj_cobertura" />
317                <pathelement location="./build/obj" />
318                <pathelement location="../../build/jbigi.jar" />
319                <pathelement location="${with.clover}" />
320                <pathelement location="${with.cobertura}" />
321            </classpath>
322            <batchtest todir="../../reports/core/junit/">
323                <fileset dir="./test/junit/">
324                    <include name="**/*Test.java" />
325                    <exclude name="**/ElGamalAESEngineTest.java" />
326                    <exclude name="**/StructureTest.java" />
327                    <!-- DataHelperTest is *very* slow with cobertura -->
328                    <!--
329                    <exclude name="**/DataHelperTest.java" />
330                    -->
331                </fileset>
332            </batchtest>
333            <formatter type="xml"/>
334        </junit>
335        <!-- set if unset -->
336        <property name="host.fakename" value="i2ptester" />
337        <!-- replace hostname that junit inserts into reports with fake one -->
338        <replaceregexp byline="true"
339            match="(hostname=)&quot;[^&quot;]+&quot;"
340            replace="\1&quot;${host.fakename}&quot;">
341            <fileset dir="../../reports/core/junit/" />
342        </replaceregexp>
343    </target>
344    <target name="test" depends="junit.test, scalatest.test"/>
345    <!-- test reports -->
346    <target name="scalatest.report">
347        <junitreport todir="../../reports/core/scalatest">
348            <fileset dir="../../reports/core/scalatest">
349                <include name="TEST-*.xml"/>
350            </fileset>
351            <report format="frames" todir="../../reports/core/html/scalatest"/>
352        </junitreport>
353    </target>
354    <target name="junit.report">
355        <junitreport todir="../../reports/core/junit">
356            <fileset dir="../../reports/core/junit">
357                <include name="TEST-*.xml"/>
358            </fileset>
359            <report format="frames" todir="../../reports/core/html/junit"/>
360        </junitreport>
361    </target>
362    <target name="clover.report" depends="test" if="with.clover">
363        <clover-report>
364            <current outfile="../../reports/core/html/clover">
365                <format type="html"/>
366            </current>
367        </clover-report>
368    </target>
369    <target name="cobertura.report" depends="test" if="with.cobertura">
370        <mkdir dir="../../reports/core/cobertura" />
371        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/core/cobertura" />
372        <mkdir dir="../../reports/core/html/cobertura" />
373        <cobertura-report format="html" srcdir="./src" destdir="../../reports/core/html/cobertura" />
374        <delete file="./cobertura.ser" />
375    </target>
376    <target name="test.report" depends="junit.report, scalatest.report, clover.report, cobertura.report"/>
377    <!-- end test reports -->
378    <target name="fulltest" depends="test, test.report" />
379    <!-- end unit tests -->
380
381    <target name="clean">
382        <delete dir="./build" />
383    </target>
384    <target name="cleandep" depends="clean">
385        <!-- noop, since the core doesn't depend on anything -->
386    </target>
387    <target name="distclean" depends="clean">
388        <!-- noop, since the core doesn't depend on anything -->
389    </target>
390</project>
Note: See TracBrowser for help on using the repository browser.