source: router/java/build.xml @ 03de374

Last change on this file since 03de374 was 1fea327, checked in by zzz <zzz@…>, 4 years ago

more jar manifest attributes

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