source: router/java/build.xml @ d28f983c

Last change on this file since d28f983c was d28f983c, checked in by zzz <zzz@…>, 4 years ago

Utils: Add main classes to i2p.jar and router.jar
for simple command line access to utilities

  • Property mode set to 100644
File size: 14.4 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            </classpath>
20        </depend>
21    </target>
22    <target name="dependVersion">
23        <!-- Force the dependency on the RouterVersion as depend doesn't recognize constant changes  -->
24        <dependset>
25             <srcfilelist dir="." files="build/obj/net/i2p/router/RouterVersion.class" />
26             <targetfilelist dir="." files="build/obj/net/i2p/router/Router.class" />
27             <targetfilelist dir="." files="build/obj/net/i2p/router/StatisticsManager.class" />
28        </dependset>
29    </target>
30
31    <!-- only used if not set by a higher build.xml -->
32    <property name="javac.compilerargs" value="" />
33    <property name="javac.version" value="1.6" />
34
35    <target name="compile" depends="depend, dependVersion">
36        <mkdir dir="./build" />
37        <mkdir dir="./build/obj" />
38        <javac srcdir="./src" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
39               debuglevel="lines,vars,source"
40               includeAntRuntime="false"
41               destdir="./build/obj" classpath="../../core/java/build/obj:../../core/java/build/i2p.jar" >
42            <compilerarg line="${javac.compilerargs}" />
43        </javac>
44    </target>
45
46    <target name="listChangedFiles" if="mtn.available" >
47        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
48            <arg value="list" />
49            <arg value="changed" />
50            <arg value="." />
51        </exec>
52        <!-- \n in an attribute value generates an invalid manifest -->
53        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
54            <arg value="-s" />
55            <arg value="[:space:]" />
56            <arg value="," />
57        </exec>
58    </target>
59
60    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
61        <!-- set if unset -->
62        <property name="workspace.changes.tr" value="" />
63        <jar destfile="./build/router.jar" basedir="./build/obj" includes="**/*.class" >
64            <manifest>
65                <!-- so people with very old wrapper.config files will still work with Jetty 6 -->
66                <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" />
67                <attribute name="Implementation-Version" value="${full.version}" />
68                <attribute name="Built-By" value="${build.built-by}" />
69                <attribute name="Build-Date" value="${build.timestamp}" />
70                <attribute name="Base-Revision" value="${workspace.version}" />
71                <attribute name="Main-Class" value="net.i2p.router.CommandLine" />
72                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
73            </manifest>
74        </jar>
75    </target>
76
77    <target name="jarUpToDate">
78        <uptodate property="jar.uptodate" targetfile="build/router.jar" >
79            <srcfiles dir= "." includes="build/obj/**/*.class" />
80        </uptodate>
81    </target>
82
83    <target name="javadoc">
84        <mkdir dir="./build" />
85        <mkdir dir="./build/javadoc" />
86        <javadoc 
87            sourcepath="./src:./test/junit:../../core/java/src:../../core/java/test/junit" destdir="./build/javadoc" 
88            packagenames="*" 
89            use="true" 
90            splitindex="true" 
91            windowtitle="I2P Router" />
92    </target>
93
94    <!-- scala paths -->
95    <target name="scala.init">
96        <property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
97        <property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
98        <taskdef resource="scala/tools/ant/antlib.xml">
99            <classpath>
100                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
101                <pathelement location="${scala-library.jar}" />
102            </classpath>
103        </taskdef>
104    </target>
105
106    <!-- unit tests -->
107    <target name="builddepscalatest">
108        <ant dir="../../core/java/" target="jar" />
109        <ant dir="../../core/java/" target="jarScalaTest" />
110    </target>
111    <target name="builddeptest">
112        <ant dir="../../core/java/" target="jarTest" />
113    </target>
114    <target name="scalatest.compileTest" depends="builddepscalatest, compile, scala.init">
115        <mkdir dir="./build" />
116        <mkdir dir="./build/obj_scala" />
117        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
118            <classpath>
119                <pathelement location="${javac.classpath}" />
120                <pathelement location="${scala-library.jar}" />
121                <pathelement location="${scalatest.jar}" />
122                <pathelement location="../../core/java/build/i2pscalatest.jar" />
123                <pathelement location="./build/obj" />
124            </classpath>
125        </scalac>
126    </target>
127
128    <target name="junit.compileTest" depends="builddeptest, compile">
129        <mkdir dir="./build" />
130        <mkdir dir="./build/obj" />
131        <!-- set hamcrest and junit homes to the old default unless overridden elsewhere -->
132        <property name="hamcrest.home" value="${ant.home}/lib/" />
133        <property name="junit.home" value="${ant.home}/lib/" />
134        <javac srcdir="./test/junit" debug="true" source="${javac.version}" target="${javac.version}" deprecation="on"
135            debuglevel="lines,vars,source"
136            includeAntRuntime="true"
137            destdir="./build/obj">
138            <classpath>
139                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
140                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
141                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
142                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
143                <pathelement location="${junit.home}/junit4.jar" />
144                <pathelement location="../../core/java/build/i2ptest.jar" />
145            </classpath>
146            <compilerarg line="${javac.compilerargs}" />
147        </javac>
148    </target>
149    <!-- jars with tests -->
150    <target name="jarScalaTest" depends="scalatest.compileTest">
151        <mkdir dir="./build/obj_scala_jar" />
152        <copy todir="./build/obj_scala_jar">
153            <fileset dir="./build/">
154                <include name="obj/**/*.class"/>
155            </fileset>
156            <mapper type="glob" from="obj/*" to="*" />
157        </copy>
158        <copy todir="./build/obj_scala_jar">
159            <fileset dir="./build/">
160                <include name="obj_scala/**/*.class"/>
161            </fileset>
162            <mapper type="glob" from="obj_scala/*" to="*" />
163        </copy>
164        <jar destfile="./build/routerscalatest.jar" basedir="./build/obj_scala_jar" includes="**/*.class" />
165    </target>
166    <target name="jarTest" depends="junit.compileTest">
167        <jar destfile="./build/routertest.jar" basedir="./build/obj" includes="**/*.class" />
168    </target>
169    <!-- preparation of code coverage tool of choice -->
170    <target name="prepareClover" depends="compile" if="with.clover">
171        <taskdef resource="clovertasks"/>
172        <mkdir dir="../../reports/router/clover" />
173        <clover-setup initString="../../reports/router/clover/coverage.db"/>
174    </target>
175    <target name="prepareCobertura" depends="compile" if="with.cobertura">
176        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
177        <mkdir dir="./build/obj_cobertura" />
178        <delete file="./cobertura.ser" />
179        <cobertura-instrument todir="./build/obj_cobertura">
180            <fileset dir="./build/obj">
181                <include name="**/*.class"/>
182                <!-- exclude Test classes -->
183                <exclude name="**/*Test.class" />
184                <!-- exclude anything not in net.i2p.* -->
185                <exclude name="org/cybergarage/**/*.class" />
186                <exclude name="org/freenetproject/**/*.class" />
187                <exclude name="org/xlattice/**/*.class" />
188            </fileset>
189        </cobertura-instrument>
190    </target>
191    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
192    <!-- end preparation of code coverage tool -->
193    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
194        <mkdir dir="../../reports/router/scalatest/" />
195        <delete>
196            <fileset dir="../../reports/router/scalatest">
197                <include name="TEST-*.xml"/>
198            </fileset>
199        </delete>
200        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
201            <classpath>
202                <pathelement location="${scala-library.jar}" />
203                <pathelement location="${scalatest.jar}" />
204                <pathelement location="./build/obj_cobertura" />
205                <pathelement location="./build/obj" />
206                <pathelement location="../../core/java/build/i2p.jar" />
207                <pathelement location="../../build/jbigi.jar" />
208                <pathelement location="${with.clover}" />
209                <pathelement location="${with.cobertura}" />
210            </classpath>
211        </taskdef>
212        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
213            <tagsToExclude>
214                SlowTests
215            </tagsToExclude>
216            <reporter type="stdout" />
217            <reporter type="junitxml" directory="../../reports/router/scalatest/" />
218        </scalatest>
219        <!-- set if unset -->
220        <property name="host.fakename" value="i2ptester" />
221        <!-- replace hostname that junit inserts into reports with fake one -->
222        <replaceregexp byline="true"
223            match="(hostname=)&quot;[^&quot;]+&quot;"
224            replace="\1&quot;${host.fakename}&quot;">
225            <fileset dir="../../reports/router/scalatest/" />
226        </replaceregexp>
227    </target>
228    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
229        <mkdir dir="../../reports/router/junit/" />
230        <delete>
231            <fileset dir="../../reports/router/junit">
232                <include name="TEST-*.xml"/>
233            </fileset>
234        </delete>
235        <junit printsummary="withOutAndErr" fork="yes" showoutput="yes" >
236            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
237            <classpath>
238                <pathelement path="${javac.classpath}" />
239                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
240                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
241                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
242                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
243                <pathelement location="${junit.home}/junit4.jar" />
244                <pathelement location="./build/obj_cobertura" />
245                <pathelement location="./build/obj" />
246                <pathelement location="../../core/java/build/i2ptest.jar" />
247                <pathelement location="../../build/jbigi.jar" />
248                <pathelement location="${with.clover}" />
249                <pathelement location="${with.cobertura}" />
250            </classpath>
251            <batchtest todir="../../reports/router/junit/">
252                <fileset dir="./test/junit">
253                    <include name="**/*Test.java" />
254                </fileset>
255            </batchtest>
256            <formatter type="xml"/>
257        </junit>
258        <!-- set if unset -->
259        <property name="host.fakename" value="i2ptester" />
260        <!-- replace hostname that junit inserts into reports with fake one -->
261        <replaceregexp byline="true"
262            match="(hostname=)&quot;[^&quot;]+&quot;"
263            replace="\1&quot;${host.fakename}&quot;">
264            <fileset dir="../../reports/router/junit/" />
265        </replaceregexp>
266    </target>
267
268    <!-- both junit and scala, but we have no scala tests yet -->
269    <target name="test" depends="junit.test"/>
270
271    <!-- test reports -->
272    <target name="scalatest.report">
273        <junitreport todir="../../reports/router/scalatest">
274            <fileset dir="../../reports/router/scalatest">
275                <include name="TEST-*.xml"/>
276            </fileset>
277            <report format="frames" todir="../../reports/router/html/scalatest"/>
278        </junitreport>
279    </target>
280    <target name="junit.report">
281        <junitreport todir="../../reports/router/junit">
282            <fileset dir="../../reports/router/junit">
283                <include name="TEST-*.xml"/>
284            </fileset>
285            <report format="frames" todir="../../reports/router/html/junit"/>
286        </junitreport>
287    </target>
288    <target name="clover.report" depends="test" if="with.clover">
289        <clover-report>
290            <current outfile="../../reports/router/html/clover">
291                <format type="html"/>
292            </current>
293        </clover-report>
294    </target>
295    <target name="cobertura.report" depends="test" if="with.cobertura">
296        <mkdir dir="../../reports/router/cobertura" />
297        <cobertura-report format="xml" srcdir="./src" destdir="../../reports/router/cobertura" />
298        <mkdir dir="../../reports/router/html/cobertura" />
299        <cobertura-report format="html" srcdir="./src" destdir="../../reports/router/html/cobertura" />
300        <delete file="./cobertura.ser" />
301    </target>
302    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
303    <!-- end test reports -->
304    <target name="fulltest" depends="cleandep, test, test.report" />
305    <!-- end unit tests -->
306
307    <target name="clean">
308        <delete dir="./build" />
309    </target>
310    <target name="cleandep" depends="clean">
311    </target>
312    <target name="distclean" depends="clean">
313    </target>
314</project>
Note: See TracBrowser for help on using the repository browser.