source: apps/routerconsole/java/build.xml @ 7213ff0c

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