source: router/java/build.xml @ 11579b9

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

merge of '8bf9850eb3fe4fcfb63053838a188969b7ba9c5b'

and 'a40ea9b5f7545281195f00a80e31ae879197e76b'

  • Property mode set to 100644
File size: 15.7 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="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
120        <taskdef resource="scala/tools/ant/antlib.xml">
121            <classpath>
122                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
123                <pathelement location="${scala-library.jar}" />
124            </classpath>
125        </taskdef>
126    </target>
127
128    <!-- unit tests -->
129    <target name="builddepscalatest">
130        <ant dir="../../core/java/" target="jar" />
131        <ant dir="../../core/java/" target="jarScalaTest" />
132    </target>
133    <target name="builddeptest">
134        <ant dir="../../core/java/" target="jarTest" />
135    </target>
136    <target name="scalatest.compileTest" depends="builddepscalatest, compile, scala.init">
137        <mkdir dir="./build" />
138        <mkdir dir="./build/obj_scala" />
139        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
140            <classpath>
141                <pathelement location="${javac.classpath}" />
142                <pathelement location="${scala-library.jar}" />
143                <pathelement location="${scalatest.jar}" />
144                <pathelement location="../../core/java/build/i2pscalatest.jar" />
145                <pathelement location="./build/obj" />
146            </classpath>
147        </scalac>
148    </target>
149
150    <target name="junit.compileTest" depends="builddeptest, compile">
151        <mkdir dir="./build" />
152        <mkdir dir="./build/obj" />
153        <!-- set hamcrest and junit homes to the old default unless overridden elsewhere -->
154        <property name="hamcrest.home" value="${ant.home}/lib/" />
155        <property name="junit.home" value="${ant.home}/lib/" />
156        <javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
157            debuglevel="lines,vars,source"
158            includeAntRuntime="true"
159            destdir="./build/obj">
160            <classpath>
161                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
162                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
163                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
164                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
165                <pathelement location="${junit.home}/junit4.jar" />
166                <pathelement location="../../core/java/build/i2ptest.jar" />
167            </classpath>
168            <compilerarg line="${javac.compilerargs}" />
169        </javac>
170    </target>
171    <!-- jars with tests -->
172    <target name="jarScalaTest" depends="scalatest.compileTest">
173        <mkdir dir="./build/obj_scala_jar" />
174        <copy todir="./build/obj_scala_jar">
175            <fileset dir="./build/">
176                <include name="obj/**/*.class"/>
177            </fileset>
178            <mapper type="glob" from="obj/*" to="*" />
179        </copy>
180        <copy todir="./build/obj_scala_jar">
181            <fileset dir="./build/">
182                <include name="obj_scala/**/*.class"/>
183            </fileset>
184            <mapper type="glob" from="obj_scala/*" to="*" />
185        </copy>
186        <jar destfile="./build/routerscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" />
187    </target>
188    <target name="jarTest" depends="junit.compileTest">
189        <jar destfile="./build/routertest.jar" basedir="./build/obj" includes="**/*.class" />
190    </target>
191    <!-- preparation of code coverage tool of choice -->
192    <target name="prepareClover" depends="compile" if="with.clover">
193        <taskdef resource="clovertasks"/>
194        <mkdir dir="../../reports/router/clover" />
195        <clover-setup initString="../../reports/router/clover/coverage.db"/>
196    </target>
197    <target name="prepareCobertura" depends="compile" if="with.cobertura">
198        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
199        <mkdir dir="./build/obj_cobertura" />
200        <delete file="./cobertura.ser" />
201        <cobertura-instrument todir="./build/obj_cobertura">
202            <fileset dir="./build/obj">
203                <include name="**/*.class"/>
204                <!-- exclude Test classes -->
205                <exclude name="**/*Test.class" />
206                <!-- exclude anything not in net.i2p.* -->
207                <exclude name="org/cybergarage/**/*.class" />
208                <exclude name="org/freenetproject/**/*.class" />
209                <exclude name="org/xlattice/**/*.class" />
210            </fileset>
211        </cobertura-instrument>
212    </target>
213    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
214    <!-- end preparation of code coverage tool -->
215    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
216        <mkdir dir="../../reports/router/scalatest/" />
217        <delete>
218            <fileset dir="../../reports/router/scalatest">
219                <include name="TEST-*.xml"/>
220            </fileset>
221        </delete>
222        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
223            <classpath>
224                <pathelement location="${scala-library.jar}" />
225                <pathelement location="${scalatest.jar}" />
226                <pathelement location="./build/obj_cobertura" />
227                <pathelement location="./build/obj" />
228                <pathelement location="../../core/java/build/i2p.jar" />
229                <pathelement location="../../build/jbigi.jar" />
230                <pathelement location="${with.clover}" />
231                <pathelement location="${with.cobertura}" />
232            </classpath>
233        </taskdef>
234        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
235            <tagsToExclude>
236                SlowTests
237            </tagsToExclude>
238            <reporter type="stdout" />
239            <reporter type="junitxml" directory="../../reports/router/scalatest/" />
240        </scalatest>
241        <!-- set if unset -->
242        <property name="host.fakename" value="i2ptester" />
243        <!-- replace hostname that junit inserts into reports with fake one -->
244        <replaceregexp byline="true"
245            match="(hostname=)&quot;[^&quot;]+&quot;"
246            replace="\1&quot;${host.fakename}&quot;">
247            <fileset dir="../../reports/router/scalatest/" />
248        </replaceregexp>
249    </target>
250    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
251        <mkdir dir="../../reports/router/junit/" />
252        <delete>
253            <fileset dir="../../reports/router/junit">
254                <include name="TEST-*.xml"/>
255            </fileset>
256        </delete>
257        <junit printsummary="withOutAndErr" fork="yes" showoutput="yes" >
258            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
259            <classpath>
260                <pathelement path="${javac.classpath}" />
261                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
262                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
263                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
264                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
265                <pathelement location="${junit.home}/junit4.jar" />
266                <pathelement location="./build/obj_cobertura" />
267                <pathelement location="./build/obj" />
268                <pathelement location="../../core/java/build/i2ptest.jar" />
269                <pathelement location="../../build/jbigi.jar" />
270                <pathelement location="${with.clover}" />
271                <pathelement location="${with.cobertura}" />
272            </classpath>
273            <batchtest todir="../../reports/router/junit/">
274                <fileset dir="./test/junit">
275                    <include name="**/*Test.java" />
276                </fileset>
277            </batchtest>
278            <formatter type="xml"/>
279        </junit>
280        <!-- set if unset -->
281        <property name="host.fakename" value="i2ptester" />
282        <!-- replace hostname that junit inserts into reports with fake one -->
283        <replaceregexp byline="true"
284            match="(hostname=)&quot;[^&quot;]+&quot;"
285            replace="\1&quot;${host.fakename}&quot;">
286            <fileset dir="../../reports/router/junit/" />
287        </replaceregexp>
288    </target>
289
290    <!-- both junit and scala, but we have no scala tests yet -->
291    <target name="test" depends="junit.test"/>
292
293    <!-- test reports -->
294    <target name="scalatest.report">
295        <junitreport todir="../../reports/router/scalatest">
296            <fileset dir="../../reports/router/scalatest">
297                <include name="TEST-*.xml"/>
298            </fileset>
299            <report format="frames" todir="../../reports/router/html/scalatest"/>
300        </junitreport>
301    </target>
302    <target name="junit.report">
303        <junitreport todir="../../reports/router/junit">
304            <fileset dir="../../reports/router/junit">
305                <include name="TEST-*.xml"/>
306            </fileset>
307            <report format="frames" todir="../../reports/router/html/junit"/>
308        </junitreport>
309    </target>
310    <target name="clover.report" depends="test" if="with.clover">
311        <clover-report>
312            <current outfile="../../reports/router/html/clover">
313                <format type="html"/>
314            </current>
315        </clover-report>
316    </target>
317    <target name="cobertura.report" depends="test" if="with.cobertura">
318        <mkdir dir="../../reports/router/cobertura" />
319        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/router/cobertura" />
320        <mkdir dir="../../reports/router/html/cobertura" />
321        <cobertura-report format="html" srcdir="./src" destdir="../../reports/router/html/cobertura" />
322        <delete file="./cobertura.ser" />
323    </target>
324    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
325    <!-- end test reports -->
326    <target name="fulltest" depends="cleandep, test, test.report" />
327    <!-- end unit tests -->
328
329    <target name="clean">
330        <delete dir="./build" />
331    </target>
332    <target name="cleandep" depends="clean">
333    </target>
334    <target name="distclean" depends="clean">
335    </target>
336</project>
Note: See TracBrowser for help on using the repository browser.