source: apps/routerconsole/java/build.xml @ 933ad52

Last change on this file since 933ad52 was 933ad52, checked in by zzz <zzz@…>, 7 years ago
  • Console: Add missing jetty jars to classpath (ticket #952) (tested with classpath from 0.7.4 wrapper.config)
  • JettyStart?: ditto
  • Remove references to now-unused jars in build.xml files
  • Property mode set to 100644
File size: 23.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="routerconsole">
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    <target name="prepare">
9        <!-- run from top level build.xml to get dependencies built -->
10    </target>
11    <condition property="no.bundle">
12        <isfalse value="${require.gettext}" />
13    </condition>
14    <condition property="depend.available">
15        <typefound name="depend" />
16    </condition>
17    <target name="depend" if="depend.available">
18        <depend
19            cache="../../../build"
20            srcdir="./src" 
21            destdir="./build/obj" >
22            <!-- Depend on classes instead of jars where available -->
23            <classpath>
24                <pathelement location="../../../core/java/build/obj" />
25                <pathelement location="../../../router/java/build/obj" />
26                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
27                <pathelement location="../../jetty/jettylib/jetty-util.jar" />
28                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
29                <pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
30                <pathelement location="../../systray/java/build/obj" />
31                <pathelement location="../../systray/java/lib/systray4j.jar" />
32                <pathelement location="../../desktopgui/build" />
33                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
34                <pathelement location="../../jrobin/jrobin-1.5.9.1.jar" />
35            </classpath>
36        </depend>
37    </target>
38    <target name="dependVersion">
39        <!-- Force the dependency on the RouterVersion as depend doesn't recognize constant changes  -->
40        <dependset>
41             <srcfilelist dir="." files="../../../router/java/build/obj/net/i2p/router/RouterVersion.class" />
42             <targetfilelist dir="." files="build/obj/net/i2p/router/web/NewsFetcher.class" />
43             <targetfilelist dir="." files="build/obj/net/i2p/router/web/OldConsoleHelper.class" />
44             <targetfilelist dir="." files="build/obj/net/i2p/router/web/PluginStarter.class" />
45             <targetfilelist dir="." files="build/obj/net/i2p/router/web/SummaryHelper.class" />
46             <targetfilelist dir="." files="build/obj/net/i2p/router/web/UpdateHandler.class" />
47        </dependset>
48    </target>
49    <property name="javac.compilerargs" value="" />
50    <target name="compile" depends="prepare, depend, dependVersion">
51        <mkdir dir="./build" />
52        <mkdir dir="./build/obj" />
53        <javac 
54            srcdir="./src" 
55            debug="true" deprecation="on" source="1.5" target="1.5" 
56            includeAntRuntime="false"
57            destdir="./build/obj">
58            <compilerarg line="${javac.compilerargs}" />
59            <classpath>
60                <pathelement location="../../../core/java/build/i2p.jar" />
61                <pathelement location="../../../router/java/build/router.jar" />
62                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
63                <pathelement location="../../jetty/jettylib/jetty-http.jar" />
64                <pathelement location="../../jetty/jettylib/jetty-io.jar" />
65                <pathelement location="../../jetty/jettylib/jetty-security.jar" />
66                <pathelement location="../../jetty/jettylib/jetty-servlet.jar" />
67                <pathelement location="../../jetty/jettylib/jetty-servlets.jar" />
68                <pathelement location="../../jetty/jettylib/jetty-util.jar" />
69                <pathelement location="../../jetty/jettylib/jetty-webapp.jar" />
70                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
71                <pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
72                <pathelement location="../../systray/java/build/systray.jar" />
73                <pathelement location="../../systray/java/lib/systray4j.jar" />
74                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
75                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
76                <pathelement location="../../jrobin/jrobin-1.5.9.1.jar" />
77            </classpath>
78        </javac>
79    </target>
80
81    <!-- the jar with the latest message classes from the jsps, and the war too -->
82    <target name="jar" depends="jar1, war, bundle" />
83
84    <!-- the jar without the latest message classes from the jsps -->
85    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
86        <exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" >
87            <arg value="list" />
88            <arg value="changed" />
89            <arg value="." />
90            <arg value="../locale" />
91        </exec>
92        <!-- \n in an attribute value generates an invalid manifest -->
93        <exec executable="tr" inputstring="${workspace.changes.j}" outputproperty="workspace.changes.j.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
94            <arg value="-s" />
95            <arg value="[:space:]" />
96            <arg value="," />
97        </exec>
98    </target>
99
100    <target name="jar1" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
101        <!-- set if unset -->
102        <property name="workspace.changes.j.tr" value="" />
103        <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class">
104            <manifest>
105                <!-- top level installer will rename to jrobin.jar -->
106                <!-- DTG added in 0.8.4, not in the classpath for very old installs, before we changed wrapper.config to specify * -->
107                <!-- very old installs don't have i2psnark,jstl,standard in the classpath... not added in WebAppConfiguration any more -->
108                <!-- All new jetty 7 jars should have been in 0.9.6, added in 0.9.7 -->
109                <attribute name="Class-Path" value="i2p.jar router.jar jrobin.jar desktopgui.jar i2psnark.jar jstl.jar standard.jar jetty-continuation.jar jetty-http.jar jetty-io.jar jetty-security.jar jetty-servlet.jar jetty-servlets.jar jetty-webapp.jar" />
110                <attribute name="Implementation-Version" value="${full.version}" />
111                <attribute name="Built-By" value="${build.built-by}" />
112                <attribute name="Build-Date" value="${build.timestamp}" />
113                <attribute name="Base-Revision" value="${workspace.version}" />
114                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
115            </manifest>
116        </jar>
117    </target>
118
119    <!-- this is tricky because the message classes go in the jar, not in the war -->
120    <target name="bundle" depends="jar1, precompilejsp" unless="no.bundle">
121        <!-- Update the messages_*.po files.
122             We need to supply the bat file for windows, and then change the fail property to true -->
123        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
124            <arg value="./bundle-messages.sh" />
125        </exec>
126        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
127            <arg value="./bundle-messages.sh" />
128        </exec>
129                <!-- multi-lang is optional -->
130        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
131            <arg value="./bundle-messages.sh" />
132        </exec>
133        <!-- jar again to get the latest messages_*.class files -->
134        <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
135    </target>
136
137
138    <target name="jarUpToDate">
139        <uptodate property="jar.uptodate" targetfile="build/routerconsole.jar" >
140            <srcfiles dir= "build/obj" includes="**/*.class" />
141        </uptodate>
142        <condition property="shouldListChanges" >
143            <and>
144                <not>
145                    <isset property="jar.uptodate" />
146                </not>
147                <isset property="mtn.available" />
148            </and>
149        </condition>
150    </target>
151
152    <target name="poupdate" depends="precompilejsp">
153        <!-- Update the messages_*.po files.
154             We need to supply the bat file for windows, and then change the fail property to true -->
155        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
156            <arg value="./bundle-messages.sh" />
157            <arg value="-p" />
158        </exec>
159        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
160            <arg value="./bundle-messages.sh" />
161            <arg value="-p" />
162        </exec>
163        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
164            <arg value="./bundle-messages.sh" />
165            <arg value="-p" />
166        </exec>
167    </target>
168
169    <target name="listChangedFiles2" depends="warUpToDate" if="shouldListChanges2" >
170        <exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
171            <arg value="list" />
172            <arg value="changed" />
173            <arg value="../jsp" />
174        </exec>
175        <!-- \n in an attribute value generates an invalid manifest -->
176        <exec executable="tr" inputstring="${workspace.changes.w}" outputproperty="workspace.changes.w.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
177            <arg value="-s" />
178            <arg value="[:space:]" />
179            <arg value="," />
180        </exec>
181    </target>
182
183    <!-- does NOT update the message classes, as those go in the jar -->
184    <target name="war" depends="precompilejsp, warUpToDate, listChangedFiles2" unless="war.uptodate" >
185        <!-- set if unset -->
186        <property name="workspace.changes.w.tr" value="" />
187        <!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
188        <war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"
189             basedir="../jsp/" excludes="web.xml, *.css, **/*.java, *.jsp, *.jsi, web-fragment.xml, web-out.xml">
190            <manifest>
191                <attribute name="Implementation-Version" value="${full.version}" />
192                <attribute name="Built-By" value="${build.built-by}" />
193                <attribute name="Build-Date" value="${build.timestamp}" />
194                <attribute name="Base-Revision" value="${workspace.version}" />
195                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
196            </manifest>
197        </war>
198    </target>
199
200    <target name="warUpToDate">
201        <uptodate property="war.uptodate" targetfile="build/routerconsole.war" >
202            <srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, *.css, **/*.java, *.jsp, *.jsi" />
203        </uptodate>
204        <condition property="shouldListChanges" >
205            <and>
206                <not>
207                    <isset property="jar.uptodate" />
208                </not>
209                <isset property="mtn.available" />
210            </and>
211        </condition>
212    </target>
213
214    <target name="precompilejsp" depends="jar1" unless="precompilejsp.uptodate">
215        <delete dir="../jsp/WEB-INF/" />
216        <delete file="../jsp/web-fragment.xml" />
217        <delete file="../jsp/web-out.xml" />
218        <mkdir dir="../jsp/WEB-INF/" />
219        <mkdir dir="../jsp/WEB-INF/classes" />
220
221        <!-- there are various jspc ant tasks, but they all seem a bit flakey -->
222        <!--
223           **     Usage: jspc <options> <jsp files>
224           **     where jsp files is
225           **         -webapp <dir>      A directory containing a web-app, whose JSP pages
226           **                            will be processed recursively
227           **     or any number of
228           **         <file>             A file to be parsed as a JSP page
229           **     where options include:
230           **         -help              Print this help message
231           **         -v                 Verbose mode
232           **         -d <dir>           Output Directory (default -Djava.io.tmpdir)
233           **         -l                 Outputs the name of the JSP page upon failure
234           **         -s                 Outputs the name of the JSP page upon success
235           **         -p <name>          Name of target package (default org.apache.jsp)
236           **         -c <name>          Name of target class name (only applies to first JSP page)
237           **         -mapped            Generates separate write() calls for each HTML line in the JSP
238           **         -die[#]            Generates an error return code (#) on fatal errors (default 1)
239           **         -uribase <dir>     The uri directory compilations should be relative to
240           **                            (default "/")
241           **         -uriroot <dir>     Same as -webapp
242           **         -compile           Compiles generated servlets
243           **         -webinc <file>     Creates a partial servlet mappings in the file
244           **         -webxml <file>     Creates a complete web.xml in the file
245           **         -ieplugin <clsid>  Java Plugin classid for Internet Explorer
246           **         -classpath <path>  Overrides java.class.path system property
247           **         -xpoweredBy        Add X-Powered-By response header
248           **         -trimSpaces        Trim spaces in template text between actions, directives
249        -->
250        <java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
251            <classpath>
252                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
253                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
254                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
255                <pathelement location="../../jetty/jettylib/commons-el.jar" />
256                <pathelement location="${ant.home}/lib/ant.jar" />
257                <pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
258                <pathelement location="../../systray/java/build/obj" />
259                <pathelement location="../../systray/java/lib/systray4j.jar" />
260                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
261                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
262                <pathelement location="build/routerconsole.jar" />
263                <pathelement location="build/" />
264                <pathelement location="../../../router/java/build/router.jar" />
265                <pathelement location="../../../core/java/build/i2p.jar" />
266            </classpath>
267            <arg value="-d" />
268            <arg value="../jsp/WEB-INF/classes" />
269            <arg value="-v" />
270            <arg value="-p" />
271            <arg value="net.i2p.router.web.jsp" />
272            <arg value="-webinc" />
273            <arg value="../jsp/web-fragment.xml" />
274            <arg value="-webapp" />
275            <arg value="../jsp/" />
276        </java>
277       
278        <javac debug="true" deprecation="on" source="1.5" target="1.5" 
279               encoding="UTF-8"
280               includeAntRuntime="false"
281               destdir="../jsp/WEB-INF/classes/" 
282               srcdir="../jsp/WEB-INF/classes" includes="**/*.java">
283            <compilerarg line="${javac.compilerargs}" />
284            <classpath>
285                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
286                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
287                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
288                <pathelement location="../../jetty/jettylib/commons-el.jar" />
289                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
290                <pathelement location="../../jetty/jettylib/jetty-util.jar" />
291                <pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
292                <pathelement location="../../systray/java/build/obj" />
293                <pathelement location="../../systray/java/lib/systray4j.jar" />
294                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
295                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
296                <pathelement location="build/routerconsole.jar" />
297                <pathelement location="build" />
298                <pathelement location="../../../router/java/build/router.jar" />
299                <pathelement location="../../../core/java/build/i2p.jar" />
300            </classpath>
301        </javac>
302
303        <!-- save these so we can run gettext on the generated java files later
304        <delete>
305            <fileset dir="../jsp/WEB-INF/" includes="**/*.java" />
306            <fileset dir="../jsp/WEB-INF/" includes="**/*.jsp" />
307        </delete>
308        -->
309        <copy file="../jsp/web.xml" tofile="../jsp/web-out.xml" />
310        <loadfile property="jspc.web.fragment" srcfile="../jsp/web-fragment.xml" />
311        <replace file="../jsp/web-out.xml">
312            <replacefilter token="&lt;!-- precompiled servlets --&gt;" value="${jspc.web.fragment}" />
313        </replace>
314    </target>
315
316    <uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
317        <srcfiles dir= "../jsp" includes="**/*.jsp, *.jsi, **/*.html, *.css, susimail/susimail, web.xml"/>
318        <!-- so the version is right on logs.jsp -->
319        <srcfiles dir= "../../../router/java/src/net/i2p/router" includes="RouterVersion.java"/>
320    </uptodate>
321
322    <target name="javadoc">
323        <mkdir dir="./build" />
324        <mkdir dir="./build/javadoc" />
325        <javadoc 
326            sourcepath="./src:../../../core/java/src:../../../router/java/src:../../systray/java/src:../../desktopgui/src" destdir="./build/javadoc" 
327            packagenames="*" 
328            use="true" 
329            splitindex="true" 
330            windowtitle="Router Console" />
331    </target>
332
333    <!-- scala paths -->
334    <target name="scala.init">
335        <property name="scala-library.jar" value="${scalatest.libs}/scala-library.jar" />
336        <property name="scalatest.jar" value="${scalatest.libs}/scalatest.jar" />
337        <taskdef resource="scala/tools/ant/antlib.xml">
338            <classpath>
339                <pathelement location="${scalatest.libs}/scala-compiler.jar" />
340                <pathelement location="${scala-library.jar}" />
341            </classpath>
342        </taskdef>
343    </target>
344
345    <!-- unit tests -->
346    <target name="builddepscalatest">
347        <ant dir="../../../router/java/" target="jar" />
348        <ant dir="../../../router/java/" target="jarScalaTest" />
349    </target>
350    <target name="scalatest.compileTest" depends="builddepscalatest, compile, scala.init">
351        <mkdir dir="./build" />
352        <mkdir dir="./build/obj_scala" />
353        <scalac srcdir="./test/scalatest" destdir="./build/obj_scala" deprecation="on" >
354            <classpath>
355                <pathelement location="${scala-library.jar}" />
356                <pathelement location="${scalatest.jar}" />
357                <pathelement location="${scalatest.libs}/mockito-all.jar" />
358                <pathelement location="../../../core/java/build/i2pscalatest.jar" />
359                <pathelement location="../../../router/java/build/routerscalatest.jar" />
360                <pathelement location="./build/obj" />
361            </classpath>
362        </scalac>
363    </target>
364    <!-- preparation of code coverage tool of choice -->
365    <target name="prepareClover" depends="compile" if="with.clover">
366        <taskdef resource="clovertasks"/>
367        <mkdir dir="../../../reports/apps/routerconsole/clover" />
368        <clover-setup initString="../../../reports/apps/routerconsole/clover/coverage.db"/>
369    </target>
370    <target name="prepareCobertura" depends="compile" if="with.cobertura">
371        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
372        <mkdir dir="./build/obj_cobertura" />
373        <delete file="./cobertura.ser" />
374        <cobertura-instrument todir="./build/obj_cobertura">
375            <fileset dir="./build/obj">
376                <include name="**/*.class"/>
377                <exclude name="**/*Test.class" />
378            </fileset>
379        </cobertura-instrument>
380    </target>
381    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
382    <!-- end preparation of code coverage tool -->
383    <target name="scalatest.test" depends="clean, scalatest.compileTest, prepareTest">
384        <mkdir dir="../../../reports/apps/routerconsole/scalatest/" />
385        <delete>
386            <fileset dir="../../../reports/apps/routerconsole/scalatest">
387                <include name="TEST-*.xml"/>
388            </fileset>
389        </delete>
390        <taskdef name="scalatest" classname="org.scalatest.tools.ScalaTestAntTask">
391            <classpath>
392                <pathelement location="${classpath}" />
393                <pathelement location="${scala-library.jar}" />
394                <pathelement location="${scalatest.jar}" />
395                <pathelement location="./build/obj_cobertura" />
396                <pathelement location="./build/obj" />
397                <pathelement location="${with.clover}" />
398                <pathelement location="${with.cobertura}" />
399            </classpath>
400        </taskdef>
401        <scalatest runpath="./build/obj_scala" fork="yes" maxmemory="384M">
402            <tagsToExclude>
403                SlowTests
404            </tagsToExclude>
405            <reporter type="stdout" />
406            <reporter type="junitxml" directory="../../../reports/apps/routerconsole/scalatest/" />
407        </scalatest>
408        <!-- fetch the real hostname of this machine -->
409        <exec executable="hostname" outputproperty="host.name"/>
410        <!-- set if unset -->
411        <property name="host.fakename" value="i2ptester" />
412        <!-- replace hostname that junit inserts into reports with fake one -->
413        <replace dir="../../../reports/apps/routerconsole/scalatest/" token="${host.name}" value="${host.fakename}"/>
414    </target>
415    <target name="test" depends="scalatest.test"/>
416    <!-- test reports -->
417    <target name="scalatest.report">
418        <junitreport todir="../../../reports/apps/routerconsole/scalatest">
419            <fileset dir="../../../reports/apps/routerconsole/scalatest">
420                <include name="TEST-*.xml"/>
421            </fileset>
422            <report format="frames" todir="../../../reports/apps/routerconsole/html/scalatest"/>
423        </junitreport>
424    </target>
425    <target name="clover.report" depends="test" if="with.clover">
426        <clover-report>
427            <current outfile="../../../reports/apps/routerconsole/html/clover">
428                <format type="html"/>
429            </current>
430        </clover-report>
431    </target>
432    <target name="cobertura.report" depends="test" if="with.cobertura">
433        <mkdir dir="../../../reports/apps/routerconsole/cobertura" />
434        <cobertura-report format="xml" srcdir="./src" destdir="../../../reports/apps/routerconsole/cobertura" />
435        <mkdir dir="../../../reports/apps/routerconsole/html/cobertura" />
436        <cobertura-report format="html" srcdir="./src" destdir="../../../reports/apps/routerconsole/html/cobertura" />
437        <delete file="./cobertura.ser" />
438    </target>
439    <target name="test.report" depends="scalatest.report, clover.report, cobertura.report"/>
440    <!-- end test reports -->
441    <target name="fulltest" depends="cleandep, test, test.report" />
442    <!-- end unit tests -->
443
444    <target name="clean">
445        <delete dir="./build" />
446        <delete dir="../jsp/WEB-INF/" />
447        <delete file="../jsp/web-fragment.xml" />
448        <delete file="../jsp/web-out.xml" />
449    </target>
450    <target name="cleandep" depends="clean">
451    </target>
452    <target name="distclean" depends="clean">
453    </target>
454</project>
Note: See TracBrowser for help on using the repository browser.