source: router/java/build.xml @ e68182a

Last change on this file since e68182a was e68182a, checked in by zzz <zzz@…>, 21 months ago

Build: Provide option to prevent Class-Path in manifests (ticket #2317)

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