source: router/java/build.xml @ 2fe1f97

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

Debian: Add runtime dependency on libhttpclient-java,
link to /usr/share/java/httpclient.jar and httpcore.jar.
This is 2 MB of dependencies to replace 20 KB of copied code,
so may not be worth it, esp. for Tails.

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