source: apps/ministreaming/java/build.xml @ 6cc39a2

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

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

  • 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="ministreaming">
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            </classpath>
20        </depend>
21    </target>
22
23    <!-- only used if not set by a higher build.xml -->
24    <property name="javac.compilerargs" value="" />
25    <property name="javac.version" value="1.7" />
26    <property name="require.gettext" value="true" />
27    <property name="manifest.classpath.name" value="Class-Path" />
28
29    <condition property="no.bundle">
30        <isfalse value="${require.gettext}" />
31    </condition>
32
33    <target name="compile" depends="depend">
34        <mkdir dir="./build" />
35        <mkdir dir="./build/obj" />
36        <!-- half of this is deprecated classes so turn deprecation off -->
37        <javac srcdir="./src" debug="true" deprecation="off" source="${javac.version}" target="${javac.version}"
38               includeAntRuntime="false"
39               destdir="./build/obj" classpath="../../../core/java/build/i2p.jar" >
40            <compilerarg line="${javac.compilerargs}" />
41        </javac>
42    </target>
43
44    <target name="compileDemo" depends="jar">
45        <mkdir dir="./buildDemo" />
46        <mkdir dir="./buildDemo/obj" />
47        <javac
48            srcdir="./demo"
49            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
50            includeAntRuntime="false"
51            destdir="./buildDemo/obj"
52            classpath="../../../core/java/build/i2p.jar:./build/mstreaming.jar" >
53            <compilerarg line="${javac.compilerargs}" />
54        </javac>
55    </target>
56
57    <target name="jarDemo" depends="jar, compileDemo">
58        <jar destfile="./build/mstreamingDemo.jar" basedir="./buildDemo/obj" includes="**/*.class" update="true" />
59    </target>
60
61    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
62        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
63            <arg value="list" />
64            <arg value="changed" />
65            <arg value="." />
66        </exec>
67        <!-- \n in an attribute value generates an invalid manifest -->
68        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
69            <arg value="-s" />
70            <arg value="[:space:]" />
71            <arg value="," />
72        </exec>
73    </target>
74
75    <target name="jar" depends="compile, bundle, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
76        <!-- set if unset -->
77        <property name="workspace.changes.tr" value="" />
78        <jar destfile="./build/mstreaming.jar" basedir="./build/obj" includes="**/*.class" >
79            <manifest>
80                <attribute name="${manifest.classpath.name}" value="i2p.jar streaming.jar" />
81                <attribute name="Specification-Title" value="I2P Streaming API" />
82                <attribute name="Specification-Version" value="${release.number}" />
83                <attribute name="Specification-Vendor" value="The I2P Project https://geti2p.net/" />
84                <attribute name="Implementation-Title" value="I2P Java Streaming Implementation" />
85                <attribute name="Implementation-Version" value="${full.version}" />
86                <attribute name="Implementation-Vendor" value="The I2P Project https://geti2p.net/" />
87                <attribute name="Built-By" value="${build.built-by}" />
88                <attribute name="Build-Date" value="${build.timestamp}" />
89                <attribute name="Base-Revision" value="${workspace.version}" />
90                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
91                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
92                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
93            </manifest>
94        </jar>
95    </target>
96
97    <target name="jarUpToDate">
98        <uptodate property="jar.uptodate" targetfile="build/mstreaming.jar" >
99            <srcfiles dir= "." includes="build/obj/**/*.class" />
100        </uptodate>
101        <condition property="shouldListChanges" >
102            <and>
103                <not>
104                    <isset property="jar.uptodate" />
105                </not>
106                <isset property="mtn.available" />
107            </and>
108        </condition>
109    </target>
110   
111    <target name="bundle" depends="compile" unless="no.bundle">
112        <mkdir dir="build/messages-src" />
113        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
114            <env key="JAVA_HOME" value="${java.home}" />
115            <arg value="./bundle-messages.sh" />
116        </exec>
117        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
118            <arg value="./bundle-messages.sh" />
119        </exec>
120        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
121            <arg value="./bundle-messages.sh" />
122        </exec>
123        <javac source="${javac.version}" target="${javac.version}" 
124               includeAntRuntime="false"
125               srcdir="build/messages-src" destdir="build/obj">
126            <compilerarg line="${javac.compilerargs}" />
127        </javac>
128    </target>
129
130    <target name="poupdate" depends="builddep, compile">
131        <!-- Update the messages_*.po files.  -->
132        <!-- set if unset -->
133        <property name="lg2" value="" />
134        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
135            <env key="LG2" value="${lg2}" />
136            <arg value="./bundle-messages.sh" />
137            <arg value="-p" />
138        </exec>
139        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
140            <env key="LG2" value="${lg2}" />
141            <arg value="./bundle-messages.sh" />
142            <arg value="-p" />
143        </exec>
144        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
145            <env key="LG2" value="${lg2}" />
146            <arg value="./bundle-messages.sh" />
147            <arg value="-p" />
148        </exec>
149    </target>
150
151    <target name="javadoc">
152        <mkdir dir="./build" />
153        <mkdir dir="./build/javadoc" />
154        <javadoc access="package"
155            source="${javac.version}"
156            destdir="./build/javadoc"
157            packagenames="*"
158            use="true"
159            splitindex="true"
160            failonerror="true"
161            additionalparam="-notimestamp"
162            doctitle="I2P Javadocs for Release ${release.number} Build ${i2p.build.number}${build.extra}"
163            windowtitle="I2P Anonymous Network - Java Documentation - Version ${release.number}">
164            <group title="Streaming Library API" packages="*" />
165            <sourcepath>
166                <pathelement location="./src" />
167            </sourcepath>
168            <classpath>
169                <pathelement location="../../../core/java/build/i2p.jar" />
170                <!-- following are only for debian builds -->
171                <pathelement location="../../../core/java/build/libintl.jar" />
172                <pathelement location="../../../core/java/build/gnu-getopt.jar" />
173            </classpath>
174            <!-- These variables are stored in build.properties.
175                  End-users can override by creating the file override.properties -->
176            <link offline="true" href="${javasedocs.url}" packagelistLoc="../../../installer/resources/package-lists/java/" />
177            <link offline="true" href="${javaeedocs.url}" packagelistLoc="../../../installer/resources/package-lists/javaee/" />
178            <link offline="true" href="${jettydocs.url}" packagelistLoc="../../../installer/resources/package-lists/jetty/" />
179            <link offline="true" href="${wrapperdocs.url}" packagelistLoc="../../../installer/resources/package-lists/wrapper/" />
180        </javadoc>
181    </target>
182
183    <!-- for Maven Central -->
184    <target name="javadocJar" depends="javadoc">
185        <jar jarfile="./build/mstreaming-${release.number}-javadoc.jar">
186            <fileset dir="./build/javadoc" />
187        </jar>
188    </target>
189    <target name="sourcesJar">
190        <jar jarfile="./build/mstreaming-${release.number}-sources.jar">
191            <fileset dir="./src" />
192        </jar>
193    </target>
194
195    <target name="builddeptest">
196        <ant dir="../../../core/java" target="jar" />
197    </target>
198    <target name="junit.compileTest" depends="builddeptest, compile">
199
200        <echo message="[DEBUG] ant home is ${ant.home}" />
201        <echo message="[DEBUG] junit home before override is ${junit.home}" />
202        <echo message="[DEBUG] hamcrest home before override is ${hamcrest.home}" />
203        <echo message="[DEBUG] mockito home before override is ${mockito.home}" />
204
205        <property name="junit.home" value="${ant.home}/lib" />
206        <property name="hamcrest.home" value="${ant.home}/lib" />
207        <property name="mockito.home" value="${ant.home}/lib" />
208
209        <echo message="[DEBUG] junit home after override is ${junit.home}" />
210        <echo message="[DEBUG] hamcrest home after override is ${hamcrest.home}" />
211        <echo message="[DEBUG] mockito home after override is ${mockito.home}" />
212
213        <javac
214            srcdir="./test/junit"
215            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
216            includeAntRuntime="false"
217            destdir="./build/obj" >
218            <classpath>
219                <pathelement path="${javac.classpath}" />
220                <pathelement location="../../../core/java/build/i2p.jar" />
221                <pathelement location="${junit.home}/junit4.jar" />
222                <pathelement location="${hamcrest.home}/hamcrest.jar" />
223                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
224                <pathelement location="${mockito.home}/byte-buddy.jar" />
225                <pathelement location="${mockito.home}/objenesis.jar" />
226                <pathelement location="${mockito.home}/mockito-core.jar" />
227            </classpath>
228            <compilerarg line="${javac.compilerargs}" />
229        </javac>
230    </target>
231
232    <!-- preparation of code coverage tool of choice -->
233    <target name="prepareClover" depends="compile" if="with.clover">
234        <taskdef resource="clovertasks"/>
235        <mkdir dir="../../../reports/ministreaming/clover" />
236        <clover-setup initString="../../../reports/ministreaming/clover/coverage.db"/>
237    </target>
238    <target name="prepareCobertura" depends="compile" if="with.cobertura">
239        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
240        <mkdir dir="./build/obj_cobertura" />
241        <delete file="./cobertura.ser" />
242        <cobertura-instrument todir="./build/obj_cobertura">
243            <fileset dir="./build/obj">
244                <include name="**/*.class"/>
245                <!-- exclude stub classes -->
246                <exclude name="net/i2p/client/streaming/I2PSocketManagerFull.class" />
247                <!-- exclude Test classes -->
248                <exclude name="**/*Test.class" />
249                <exclude name="net/i2p/client/streaming/impl/I2PSocketManagerFull.class" />
250                <!-- exclude anything not in net.i2p.* -->
251                <exclude name="org/cybergarage/**/*.class" />
252                <exclude name="org/freenetproject/**/*.class" />
253                <exclude name="org/xlattice/**/*.class" />
254            </fileset>
255        </cobertura-instrument>
256    </target>
257
258    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
259
260    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
261        <mkdir dir="../../../reports/ministreaming/junit/" />
262        <delete>
263            <fileset dir="../../../reports/ministreaming/junit">
264                <include name="TEST-*.xml"/>
265            </fileset>
266        </delete>
267
268        <property name="junit.home" value="${ant.home}/lib" />
269        <property name="hamcrest.home" value="${ant.home}/lib" />
270        <property name="mockito.home" value="${ant.home}/lib" />
271
272        <junit printsummary="withOutAndErr" fork="yes" showoutput="yes" >
273            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
274            <classpath>
275                <pathelement path="${javac.classpath}" />
276                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
277                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
278                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
279                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
280                <pathelement location="${mockito.home}/byte-buddy.jar" />
281                <pathelement location="${mockito.home}/objenesis.jar" />
282                <pathelement location="${mockito.home}/mockito-core.jar" />
283                <pathelement location="${junit.home}/junit4.jar" />
284                <pathelement location="./build/obj_cobertura" />
285                <pathelement location="./build/obj" />
286                <pathelement location="../../../core/java/build/i2ptest.jar" />
287                <pathelement location="../../../core/java/build/i2p.jar" />
288                <pathelement location="../../build/jbigi.jar" />
289                <pathelement location="${with.clover}" />
290                <pathelement location="${with.cobertura}" />
291            </classpath>
292            <batchtest todir="../../../reports/ministreaming/junit/">
293                <fileset dir="./test/junit">
294                    <include name="**/*Test.java" />
295                </fileset>
296            </batchtest>
297            <formatter type="xml"/>
298        </junit>
299        <!-- set if unset -->
300        <property name="host.fakename" value="i2ptester" />
301        <!-- replace hostname that junit inserts into reports with fake one -->
302        <replaceregexp byline="true"
303            match="(hostname=)&quot;[^&quot;]+&quot;"
304            replace="\1&quot;${host.fakename}&quot;">
305            <fileset dir="../../../reports/ministreaming/junit/" />
306        </replaceregexp>
307    </target>
308    <target name="test" depends="junit.test"/>
309    <!-- test reports -->
310    <target name="junit.report">
311        <junitreport todir="../../../reports/ministreaming/junit">
312            <fileset dir="../../../reports/ministreaming/junit">
313                <include name="TEST-*.xml"/>
314            </fileset>
315            <report format="frames" todir="../../../reports/ministreaming/html/junit"/>
316        </junitreport>
317    </target>
318    <target name="clover.report" depends="test" if="with.clover">
319        <clover-report>
320            <current outfile="../../../reports/ministreaming/html/clover">
321                <format type="html"/>
322            </current>
323        </clover-report>
324    </target>
325    <target name="cobertura.report" depends="test" if="with.cobertura">
326        <mkdir dir="../../../reports/ministreaming/cobertura" />
327        <cobertura-report format="xml" srcdir="./src" destdir="../../../reports/ministreaming/cobertura" />
328        <mkdir dir="../../../reports/ministreaming/html/cobertura" />
329        <cobertura-report format="html" srcdir="./src" destdir="../../../reports/ministreaming/html/cobertura" />
330        <delete file="./cobertura.ser" />
331    </target>
332    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
333    <!-- end test reports -->
334    <target name="fulltest" depends="cleandep, test, test.report" />
335    <!-- end unit tests -->
336
337    <target name="clean">
338        <delete dir="./build" />
339        <delete dir="./buildDemo" />
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.