source: apps/routerconsole/java/build.xml @ 2c0e6a3

Last change on this file since 2c0e6a3 was c5f04ee, checked in by zzz <zzz@…>, 9 years ago
  • Don't do 'mtn list changed' if not in a workspace or not needed
  • Property mode set to 100644
File size: 16.0 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="depend.available">
12        <typefound name="depend" />
13    </condition>
14    <target name="depend" if="depend.available">
15        <depend
16            cache="../../../build"
17            srcdir="./src" 
18            destdir="./build/obj" >
19            <!-- Depend on classes instead of jars where available -->
20            <classpath>
21                <pathelement location="../../../core/java/build/obj" />
22                <pathelement location="../../../router/java/build/obj" />
23                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
24                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
25                <pathelement location="../../systray/java/build/obj" />
26                <pathelement location="../../systray/java/lib/systray4j.jar" />
27                <pathelement location="../../desktopgui/build" />
28                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
29                <pathelement location="../../jrobin/jrobin-1.5.9.1.jar" />
30            </classpath>
31        </depend>
32    </target>
33    <target name="dependVersion">
34        <!-- Force the dependency on the RouterVersion as depend doesn't recognize constant changes  -->
35        <dependset>
36             <srcfilelist dir="." files="../../../router/java/build/obj/net/i2p/router/RouterVersion.class" />
37             <targetfilelist dir="." files="build/obj/net/i2p/router/web/NewsFetcher.class" />
38             <targetfilelist dir="." files="build/obj/net/i2p/router/web/SummaryHelper.class" />
39             <targetfilelist dir="." files="build/obj/net/i2p/router/web/UpdateHandler.class" />
40        </dependset>
41    </target>
42    <property name="javac.compilerargs" value="" />
43    <target name="compile" depends="prepare, depend, dependVersion">
44        <mkdir dir="./build" />
45        <mkdir dir="./build/obj" />
46        <javac 
47            srcdir="./src" 
48            debug="true" deprecation="on" source="1.5" target="1.5" 
49            includeAntRuntime="false"
50            destdir="./build/obj">
51            <compilerarg line="${javac.compilerargs}" />
52            <classpath>
53                <pathelement location="../../../core/java/build/i2p.jar" />
54                <pathelement location="../../../router/java/build/router.jar" />
55                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
56                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
57                <pathelement location="../../systray/java/build/systray.jar" />
58                <pathelement location="../../systray/java/lib/systray4j.jar" />
59                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
60                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
61                <pathelement location="../../jrobin/jrobin-1.5.9.1.jar" />
62            </classpath>
63        </javac>
64    </target>
65
66    <!-- the jar with the latest message classes from the jsps, and the war too -->
67    <target name="jar" depends="jar1, war, bundle" />
68
69    <!-- the jar without the latest message classes from the jsps -->
70    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
71        <exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" >
72            <arg value="list" />
73            <arg value="changed" />
74            <arg value="." />
75            <arg value="../locale" />
76        </exec>
77        <!-- \n in an attribute value generates an invalid manifest -->
78        <exec executable="tr" inputstring="${workspace.changes.j}" outputproperty="workspace.changes.j.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
79            <arg value="-s" />
80            <arg value="[:space:]" />
81            <arg value="," />
82        </exec>
83    </target>
84
85    <target name="jar1" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
86        <!-- set if unset -->
87        <property name="workspace.changes.j.tr" value="" />
88        <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class">
89            <manifest>
90                <!-- top level installer will rename to jrobin.jar -->
91                <!-- DTG added in 0.8.4, not in the classpath for very old installs, before we changed wrapper.config to specify * -->
92                <attribute name="Class-Path" value="i2p.jar router.jar jrobin.jar desktopgui.jar" />
93                <attribute name="Build-Date" value="${build.timestamp}" />
94                <attribute name="Base-Revision" value="${workspace.version}" />
95                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
96            </manifest>
97        </jar>
98    </target>
99
100    <!-- this is tricky because the message classes go in the jar, not in the war -->
101    <target name="bundle" depends="jar1, precompilejsp" >
102        <!-- Update the messages_*.po files.
103             We need to supply the bat file for windows, and then change the fail property to true -->
104        <exec executable="sh" osfamily="unix" failifexecutionfails="true" >
105            <arg value="./bundle-messages.sh" />
106        </exec>
107        <exec executable="sh" osfamily="mac" failifexecutionfails="true" >
108            <arg value="./bundle-messages.sh" />
109        </exec>
110                <!-- multi-lang is optional -->
111        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
112            <arg value="./bundle-messages.sh" />
113        </exec>
114        <!-- jar again to get the latest messages_*.class files -->
115        <jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
116    </target>
117
118
119    <target name="jarUpToDate">
120        <uptodate property="jar.uptodate" targetfile="build/routerconsole.jar" >
121            <srcfiles dir= "build/obj" includes="**/*.class" />
122        </uptodate>
123        <condition property="shouldListChanges" >
124            <and>
125                <not>
126                    <isset property="jar.uptodate" />
127                </not>
128                <isset property="mtn.available" />
129            </and>
130        </condition>
131    </target>
132
133    <target name="poupdate" depends="precompilejsp">
134        <!-- Update the messages_*.po files.
135             We need to supply the bat file for windows, and then change the fail property to true -->
136        <exec executable="sh" osfamily="unix" failifexecutionfails="true" >
137            <arg value="./bundle-messages.sh" />
138            <arg value="-p" />
139        </exec>
140        <exec executable="sh" osfamily="mac" failifexecutionfails="true" >
141            <arg value="./bundle-messages.sh" />
142            <arg value="-p" />
143        </exec>
144        <exec executable="sh" osfamily="windows" failifexecutionfails="true" >
145            <arg value="./bundle-messages.sh" />
146            <arg value="-p" />
147        </exec>
148    </target>
149
150    <target name="listChangedFiles2" depends="warUpToDate" if="shouldListChanges2" >
151        <exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
152            <arg value="list" />
153            <arg value="changed" />
154            <arg value="../jsp" />
155        </exec>
156        <!-- \n in an attribute value generates an invalid manifest -->
157        <exec executable="tr" inputstring="${workspace.changes.w}" outputproperty="workspace.changes.w.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
158            <arg value="-s" />
159            <arg value="[:space:]" />
160            <arg value="," />
161        </exec>
162    </target>
163
164    <!-- does NOT update the message classes, as those go in the jar -->
165    <target name="war" depends="precompilejsp, warUpToDate, listChangedFiles2" unless="war.uptodate" >
166        <!-- set if unset -->
167        <property name="workspace.changes.w.tr" value="" />
168        <!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
169        <war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"
170             basedir="../jsp/" excludes="web.xml, *.css, **/*.java, *.jsp, *.jsi, web-fragment.xml, web-out.xml">
171            <manifest>
172                <attribute name="Build-Date" value="${build.timestamp}" />
173                <attribute name="Base-Revision" value="${workspace.version}" />
174                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
175            </manifest>
176        </war>
177    </target>
178
179    <target name="warUpToDate">
180        <uptodate property="war.uptodate" targetfile="build/routerconsole.war" >
181            <srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, *.css, **/*.java, *.jsp, *.jsi" />
182        </uptodate>
183        <condition property="shouldListChanges" >
184            <and>
185                <not>
186                    <isset property="jar.uptodate" />
187                </not>
188                <isset property="mtn.available" />
189            </and>
190        </condition>
191    </target>
192
193    <target name="precompilejsp" depends="jar1" unless="precompilejsp.uptodate">
194        <delete dir="../jsp/WEB-INF/" />
195        <delete file="../jsp/web-fragment.xml" />
196        <delete file="../jsp/web-out.xml" />
197        <mkdir dir="../jsp/WEB-INF/" />
198        <mkdir dir="../jsp/WEB-INF/classes" />
199
200        <!-- there are various jspc ant tasks, but they all seem a bit flakey -->
201        <!--
202           **     Usage: jspc <options> <jsp files>
203           **     where jsp files is
204           **         -webapp <dir>      A directory containing a web-app, whose JSP pages
205           **                            will be processed recursively
206           **     or any number of
207           **         <file>             A file to be parsed as a JSP page
208           **     where options include:
209           **         -help              Print this help message
210           **         -v                 Verbose mode
211           **         -d <dir>           Output Directory (default -Djava.io.tmpdir)
212           **         -l                 Outputs the name of the JSP page upon failure
213           **         -s                 Outputs the name of the JSP page upon success
214           **         -p <name>          Name of target package (default org.apache.jsp)
215           **         -c <name>          Name of target class name (only applies to first JSP page)
216           **         -mapped            Generates separate write() calls for each HTML line in the JSP
217           **         -die[#]            Generates an error return code (#) on fatal errors (default 1)
218           **         -uribase <dir>     The uri directory compilations should be relative to
219           **                            (default "/")
220           **         -uriroot <dir>     Same as -webapp
221           **         -compile           Compiles generated servlets
222           **         -webinc <file>     Creates a partial servlet mappings in the file
223           **         -webxml <file>     Creates a complete web.xml in the file
224           **         -ieplugin <clsid>  Java Plugin classid for Internet Explorer
225           **         -classpath <path>  Overrides java.class.path system property
226           **         -xpoweredBy        Add X-Powered-By response header
227           **         -trimSpaces        Trim spaces in template text between actions, directives
228        -->
229        <java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
230            <classpath>
231                <pathelement location="../../jetty/jettylib/jasper-compiler.jar" />
232                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
233                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
234                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
235                <pathelement location="../../jetty/jettylib/commons-el.jar" />
236                <pathelement location="../../jetty/jettylib/ant.jar" />
237                <pathelement location="../../systray/java/build/obj" />
238                <pathelement location="../../systray/java/lib/systray4j.jar" />
239                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
240                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
241                <pathelement location="build/routerconsole.jar" />
242                <pathelement location="build/" />
243                <pathelement location="../../../router/java/build/router.jar" />
244                <pathelement location="../../../core/java/build/i2p.jar" />
245            </classpath>
246            <arg value="-d" />
247            <arg value="../jsp/WEB-INF/classes" />
248            <arg value="-v" />
249            <arg value="-p" />
250            <arg value="net.i2p.router.web.jsp" />
251            <arg value="-webinc" />
252            <arg value="../jsp/web-fragment.xml" />
253            <arg value="-webapp" />
254            <arg value="../jsp/" />
255        </java>
256       
257        <javac debug="true" deprecation="on" source="1.5" target="1.5" 
258               encoding="UTF-8"
259               includeAntRuntime="false"
260               destdir="../jsp/WEB-INF/classes/" 
261               srcdir="../jsp/WEB-INF/classes" includes="**/*.java">
262            <compilerarg line="${javac.compilerargs}" />
263            <classpath>
264                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
265                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
266                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
267                <pathelement location="../../jetty/jettylib/commons-el.jar" />
268                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
269                <pathelement location="../../systray/java/build/obj" />
270                <pathelement location="../../systray/java/lib/systray4j.jar" />
271                <pathelement location="../../desktopgui/dist/desktopgui.jar" />
272                <pathelement location="../../../installer/lib/wrapper/all/wrapper.jar" />
273                <pathelement location="build/routerconsole.jar" />
274                <pathelement location="build" />
275                <pathelement location="../../../router/java/build/router.jar" />
276                <pathelement location="../../../core/java/build/i2p.jar" />
277            </classpath>
278        </javac>
279
280        <!-- save these so we can run gettext on the generated java files later
281        <delete>
282            <fileset dir="../jsp/WEB-INF/" includes="**/*.java" />
283            <fileset dir="../jsp/WEB-INF/" includes="**/*.jsp" />
284        </delete>
285        -->
286        <copy file="../jsp/web.xml" tofile="../jsp/web-out.xml" />
287        <loadfile property="jspc.web.fragment" srcfile="../jsp/web-fragment.xml" />
288        <replace file="../jsp/web-out.xml">
289            <replacefilter token="&lt;!-- precompiled servlets --&gt;" value="${jspc.web.fragment}" />
290        </replace>
291    </target>
292
293    <uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
294        <srcfiles dir= "../jsp" includes="**/*.jsp, *.jsi, **/*.html, *.css, susimail/susimail, web.xml"/>
295    </uptodate>
296
297    <target name="javadoc">
298        <mkdir dir="./build" />
299        <mkdir dir="./build/javadoc" />
300        <javadoc 
301            sourcepath="./src:../../../core/java/src:../../../router/java/src:../../systray/java/src:../../desktopgui/src" destdir="./build/javadoc" 
302            packagenames="*" 
303            use="true" 
304            splitindex="true" 
305            windowtitle="Router Console" />
306    </target>
307    <target name="clean">
308        <delete dir="./build" />
309        <delete dir="../jsp/WEB-INF/" />
310        <delete file="../jsp/web-fragment.xml" />
311        <delete file="../jsp/web-out.xml" />
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.