source: core/java/build.xml @ 7c7b0cb

Last change on this file since 7c7b0cb was 6cc39a2, checked in by zzz <zzz@…>, 16 months ago

Build: Fix up javadoc targets in sub-build.xml files for maven central

  • Property mode set to 100644
File size: 24.5 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 access="package"
139            source="${javac.version}"
140            destdir="./build/javadoc"
141            packagenames="*"
142            use="true"
143            splitindex="true"
144            failonerror="true"
145            additionalparam="-notimestamp"
146            doctitle="I2P Javadocs for Release ${release.number} Build ${i2p.build.number}${build.extra}"
147            windowtitle="I2P Anonymous Network - Java Documentation - Version ${release.number}">
148            <group title="Core SDK (i2p.jar)" packages="*" />
149            <sourcepath>
150                <pathelement location="./src" />
151                <pathelement location="./test/junit" />
152            </sourcepath>
153            <classpath>
154                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
155                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
156                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
157                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
158                <pathelement location="${junit.home}/junit4.jar" />
159                <!-- following are only for debian builds -->
160                <pathelement location="build/libintl.jar" />
161                <pathelement location="build/gnu-getopt.jar" />
162                <pathelement location="build/json-simple.jar" />
163            </classpath>
164            <!-- These variables are stored in build.properties.
165                  End-users can override by creating the file override.properties -->
166            <link offline="true" href="${javasedocs.url}" packagelistLoc="../../installer/resources/package-lists/java/" />
167            <link offline="true" href="${javaeedocs.url}" packagelistLoc="../../installer/resources/package-lists/javaee/" />
168            <link offline="true" href="${jettydocs.url}" packagelistLoc="../../installer/resources/package-lists/jetty/" />
169            <link offline="true" href="${wrapperdocs.url}" packagelistLoc="../../installer/resources/package-lists/wrapper/" />
170        </javadoc>
171    </target>
172
173    <!-- for Maven Central -->
174    <target name="javadocJar" depends="javadoc">
175        <jar jarfile="./build/i2p-${release.number}-javadoc.jar">
176            <fileset dir="./build/javadoc" />
177        </jar>
178    </target>
179    <target name="sourcesJar">
180        <jar jarfile="./build/i2p-${release.number}-sources.jar">
181            <fileset dir="./src" />
182        </jar>
183    </target>
184
185    <!-- scala paths -->
186    <target name="scala.init">
187        <property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
188        <property name="scala-xml.jar" value="${scalatest.libs}/scala-xml.jar" />
189        <property name="scalactic.jar" value="${scalatest.libs}/scalactic.jar" />
190        <property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
191        <taskdef resource="scala/tools/ant/antlib.xml">
192            <classpath>
193                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
194                <pathelement location="${scalatest.libs}/scala-reflect.jar" />
195                <pathelement location="${scala-library.jar}" />
196            </classpath>
197        </taskdef>
198    </target>
199
200    <!-- unit tests -->
201    <target name="scalatest.compileTest" depends="compile, scala.init">
202        <mkdir dir="./build" />
203        <mkdir dir="./build/obj_scala" />
204        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
205            <classpath>
206                <pathelement path="${javac.classpath.mod}" />
207                <pathelement location="${scala-library.jar}" />
208                <pathelement location="${scalactic.jar}" />
209                <pathelement location="${scalatest.jar}" />
210                <pathelement location="./build/obj" />
211            </classpath>
212        </scalac>
213    </target>
214    <target name="junit.compileTest" depends="compile">
215        <mkdir dir="./build" />
216        <mkdir dir="./build/obj" />
217        <!-- set hamcrest and junit homes to the old default unless overridden elsewhere -->
218        <echo message="[DEBUG] ant home is ${ant.home}" />
219        <echo message="[DEBUG] junit home before override is ${junit.home}" />
220        <echo message="[DEBUG] hamcrest home before override is ${hamcrest.home}" />
221        <property name="hamcrest.home" value="${ant.home}/lib/" />
222        <property name="junit.home" value="${ant.home}/lib/" />
223        <echo message="[DEBUG] junit home after override is ${junit.home}" />
224        <echo message="[DEBUG] hamcrest home after override is ${hamcrest.home}" />
225        <javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
226               debuglevel="lines,vars,source"
227               includeAntRuntime="true"
228               excludes="${source.exclude}"
229               destdir="./build/obj" >
230            <classpath>
231                <pathelement path="${javac.classpath.mod}" />
232                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
233                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
234                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
235                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
236                <pathelement location="${junit.home}/junit4.jar" />
237            </classpath>
238            <compilerarg line="${javac.compilerargs}" />
239        </javac>
240        <!-- EdDSA test vectors -->
241        <copy todir="./build/obj">
242            <fileset dir="./test/junit/">
243                <include name="net/i2p/crypto/eddsa/test.data"/>
244                <include name="net/i2p/crypto/eddsa/math/baseDblPrecmp"/>
245                <include name="net/i2p/crypto/eddsa/math/basePrecmp"/>
246            </fileset>
247        </copy>
248    </target>
249    <!-- jars with tests -->
250    <target name="jarScalaTest" depends="scalatest.compileTest">
251        <mkdir dir="./build/obj_scala_jar" />
252        <copy todir="./build/obj_scala_jar">
253            <fileset dir="./build/">
254                <include name="obj/**/*.class"/>
255            </fileset>
256            <mapper type="glob" from="obj/*" to="*" />
257        </copy>
258        <copy todir="./build/obj_scala_jar">
259            <fileset dir="./build/">
260                <include name="obj_scala/**/*.class"/>
261            </fileset>
262            <mapper type="glob" from="obj_scala/*" to="*" />
263        </copy>
264        <jar destfile="./build/i2pscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" />
265    </target>
266    <target name="jarTest" depends="junit.compileTest">
267        <!-- warning - The junit.test target below doesn't actually include i2ptest.jar in the classpath,
268             only the build/obj directory.
269          -->
270        <jar destfile="./build/i2ptest.jar" basedir="./build/obj" >
271            <fileset dir="./build/obj" includes="**/*.class **/test.data **/baseDblPrecmp **/basePrecmp" />
272            <!-- the getopt translation files -->
273            <fileset dir="src" includes="${translation.includes}" />
274        </jar>
275    </target>
276    <!-- preparation of code coverage tool of choice -->
277    <target name="prepareClover" depends="compile" if="with.clover">
278        <taskdef resource="clovertasks"/>
279        <mkdir dir="../../reports/core/clover" />
280        <clover-setup initString="../../reports/core/clover/coverage.db"/>
281    </target>
282    <target name="prepareCobertura" depends="compile" if="with.cobertura">
283        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
284        <mkdir dir="./build/obj_cobertura" />
285        <delete file="./cobertura.ser" />
286        <cobertura-instrument todir="./build/obj_cobertura">
287            <fileset dir="./build/obj">
288                <include name="**/*.class"/>
289                <!-- exclude Test classes -->
290                <exclude name="**/*Test.class" />
291                <exclude name="**/*TestSuite.class" />
292                <!-- specific excludes -->
293                <exclude name="**/AllCoreTests.class" />
294                <exclude name="**/stat/SimpleStatDumper.class" />
295                <exclude name="**/stat/SizeMeasure.class" />
296                <exclude name="**/stat/StatLogSplitter.class" />
297                <!-- exclude anything not in net.i2p.* -->
298                <exclude name="com/nettgryppa/**/*.class" />
299                <exclude name="freenet/**/*.class" />
300                <exclude name="gnu/**/*.class" />
301                <exclude name="net/metanotion/**/*.class" />
302                <exclude name="org/bouncycastle/**/*.class" />
303                <exclude name="org/xlattice/**/*.class" />
304            </fileset>
305        </cobertura-instrument>
306    </target>
307    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
308    <!-- end preparation of code coverage tool -->
309    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
310        <mkdir dir="../../reports/core/scalatest/" />
311        <delete>
312            <fileset dir="../../reports/core/scalatest">
313                <include name="TEST-*.xml"/>
314            </fileset>
315        </delete>
316        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
317            <classpath>
318                <pathelement location="${scala-library.jar}" />
319                <pathelement location="${scala-xml.jar}" />
320                <pathelement location="${scalactic.jar}" />
321                <pathelement location="${scalatest.jar}" />
322                <pathelement location="./build/obj_cobertura" />
323                <pathelement location="./build/obj" />
324                <pathelement location="../../build/jbigi.jar" />
325                <pathelement location="${with.clover}" />
326                <pathelement location="${with.cobertura}" />
327            </classpath>
328        </taskdef>
329        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
330            <tagsToExclude>
331                SlowTests
332            </tagsToExclude>
333            <reporter type="stdout" />
334            <reporter type="junitxml" directory="../../reports/core/scalatest/" />
335        </scalatest>
336        <!-- set if unset -->
337        <property name="host.fakename" value="i2ptester" />
338        <!-- replace hostname that junit inserts into reports with fake one -->
339        <replaceregexp byline="true"
340            match="(hostname=)&quot;[^&quot;]+&quot;"
341            replace="\1&quot;${host.fakename}&quot;">
342            <fileset dir="../../reports/core/scalatest/" />
343        </replaceregexp>
344    </target>
345    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
346        <property name="hamcrest.home" value="${ant.home}/lib/" />
347        <property name="junit.home" value="${ant.home}/lib/" />
348        <mkdir dir="../../reports/core/junit/" />
349        <delete>
350            <fileset dir="../../reports/core/junit">
351                <include name="TEST-*.xml"/>
352            </fileset>
353        </delete>
354        <junit printsummary="withOutAndErr" fork="yes" maxmemory="384m" showoutput="yes" >
355            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
356            <classpath>
357                <pathelement location="../../installer/resources/" />
358                <pathelement path="${javac.classpath.mod}" />
359                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
360                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
361                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
362                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
363                <pathelement location="${junit.home}/junit4.jar" />
364                <pathelement location="./build/obj_cobertura" />
365                <pathelement location="./build/obj" />
366                <pathelement location="../../build/jbigi.jar" />
367                <pathelement location="${with.clover}" />
368                <pathelement location="${with.cobertura}" />
369            </classpath>
370            <batchtest todir="../../reports/core/junit/">
371                <fileset dir="./test/junit/">
372                    <include name="**/*Test.java" />
373                    <include name="**/*IT.java" if="runIntegrationTests" />
374                    <exclude name="**/ElGamalAESEngineTest.java" />
375                    <exclude name="**/StructureTest.java" />
376                    <exclude name="**/AbstractFieldElementTest.java" />
377                    <!-- DataHelperTest is *very* slow with cobertura -->
378                    <!--
379                    <exclude name="**/DataHelperTest.java" />
380                    -->
381                </fileset>
382            </batchtest>
383            <formatter type="xml"/>
384        </junit>
385        <!-- set if unset -->
386        <property name="host.fakename" value="i2ptester" />
387        <!-- replace hostname that junit inserts into reports with fake one -->
388        <replaceregexp byline="true"
389            match="(hostname=)&quot;[^&quot;]+&quot;"
390            replace="\1&quot;${host.fakename}&quot;">
391            <fileset dir="../../reports/core/junit/" />
392        </replaceregexp>
393    </target>
394    <target name="test" depends="junit.test, scalatest.test"/>
395    <!-- test reports -->
396    <target name="scalatest.report">
397        <junitreport todir="../../reports/core/scalatest">
398            <fileset dir="../../reports/core/scalatest">
399                <include name="TEST-*.xml"/>
400            </fileset>
401            <report format="frames" todir="../../reports/core/html/scalatest"/>
402        </junitreport>
403    </target>
404    <target name="junit.report">
405        <junitreport todir="../../reports/core/junit">
406            <fileset dir="../../reports/core/junit">
407                <include name="TEST-*.xml"/>
408            </fileset>
409            <report format="frames" todir="../../reports/core/html/junit"/>
410        </junitreport>
411    </target>
412    <target name="clover.report" depends="test" if="with.clover">
413        <clover-report>
414            <current outfile="../../reports/core/html/clover">
415                <format type="html"/>
416            </current>
417        </clover-report>
418    </target>
419    <target name="cobertura.report" depends="test" if="with.cobertura">
420        <mkdir dir="../../reports/core/cobertura" />
421        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/core/cobertura" />
422        <mkdir dir="../../reports/core/html/cobertura" />
423        <cobertura-report format="html" srcdir="./src" destdir="../../reports/core/html/cobertura" />
424        <delete file="./cobertura.ser" />
425    </target>
426    <target name="test.report" depends="junit.report, scalatest.report, clover.report, cobertura.report"/>
427    <!-- end test reports -->
428    <target name="fulltest" depends="test, test.report" />
429    <!-- end unit tests -->
430
431    <!-- benchmarks -->
432    <target name="jmhLibCheck">
433        <!-- override to Ant home if not set -->
434        <property name="jmh.home" value="${ant.home}/lib" />
435        <fail message="Please set jmh.home to a directory containing the necessary JMH libraries. See build.properties for details.">
436            <condition>
437                <not>
438                    <and>
439                        <available file="${jmh.home}/jmh-core.jar" />
440                        <available file="${jmh.home}/jmh-generator-annprocess.jar" />
441                        <available file="${jmh.home}/jopt-simple.jar" />
442                        <available file="${jmh.home}/commons-math3.jar" />
443                    </and>
444                </not>
445            </condition>
446        </fail>
447    </target>
448
449    <target name="bench.compile" depends="compile, jmhLibCheck">
450        <mkdir dir="./build" />
451        <mkdir dir="./build/obj_bench" />
452        <javac srcdir="./bench" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
453               debuglevel="lines,vars,source"
454               includeAntRuntime="false"
455               destdir="./build/obj_bench" >
456            <classpath>
457                <pathelement location="${jmh.home}/jmh-core.jar" />
458                <pathelement location="${jmh.home}/jmh-generator-annprocess.jar" />
459                <pathelement location="./build/obj" />
460            </classpath>
461            <compilerarg line="${javac.compilerargs}" />
462        </javac>
463    </target>
464
465    <target name="bench.jar" depends="bench.compile, bench.jarUpToDate, listChangedFiles" unless="bench.jar.uptodate" >
466        <!-- set if unset -->
467        <property name="workspace.changes.tr" value="" />
468        <jar destfile="./build/i2p-benchmarks.jar" basedir="./build/obj_bench" >
469            <manifest>
470                <attribute name="Built-By" value="${build.built-by}" />
471                <attribute name="Build-Date" value="${build.timestamp}" />
472                <attribute name="Base-Revision" value="${workspace.version}" />
473                <attribute name="Main-Class" value="org.openjdk.jmh.Main" />
474                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
475                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
476                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
477            </manifest>
478            <zipfileset src="${jmh.home}/jmh-core.jar" excludes="**/META-INF/services/**" />
479            <zipfileset src="${jmh.home}/jopt-simple.jar" />
480            <zipfileset src="${jmh.home}/commons-math3.jar" />
481            <fileset dir="./build/obj" includes="**/*.class" />
482        </jar>
483    </target>
484
485    <target name="bench.jarUpToDate">
486        <uptodate property="bench.jar.uptodate" targetfile="build/i2p-benchmarks.jar" >
487            <srcfiles dir= "build/obj" includes="**/*.class" />
488            <srcfiles dir= "build/obj_bench" includes="**/*.class" />
489        </uptodate>
490    </target>
491
492    <target name="clean">
493        <delete dir="./build" />
494    </target>
495    <target name="cleandep" depends="clean">
496        <!-- noop, since the core doesn't depend on anything -->
497    </target>
498    <target name="distclean" depends="clean">
499        <!-- noop, since the core doesn't depend on anything -->
500    </target>
501</project>
Note: See TracBrowser for help on using the repository browser.