source: core/java/build.xml @ 5ca9802

Last change on this file since 5ca9802 was d263e42, checked in by zzz <zzz@…>, 21 months ago

Debian: Add libjson-simple-java dependency

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