source: apps/routerconsole/java/build.xml @ 47876d6

Last change on this file since 47876d6 was 47876d6, checked in by zzz <zzz@…>, 9 years ago

prevent stale build version on logs.jsp

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