source: apps/i2ptunnel/java/build.xml @ 8fac5c0

Last change on this file since 8fac5c0 was 8fac5c0, checked in by zzz <zzz@…>, 6 years ago

fix i2ptunnel.war

  • Property mode set to 100644
File size: 16.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="i2ptunnel">
3    <target name="all" depends="clean, build" />
4    <target name="build" depends="builddep, jar, war" />
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="../../ministreaming/java/build/obj" />
20            </classpath>
21        </depend>
22    </target>
23
24    <condition property="no.bundle">
25        <isfalse value="${require.gettext}" />
26    </condition>
27
28    <!-- only used if not set by a higher build.xml -->
29    <property name="javac.compilerargs" value="" />
30    <property name="javac.version" value="1.6" />
31    <property name="require.gettext" value="true" />
32
33    <target name="compile" depends="depend">
34        <mkdir dir="./build" />
35        <mkdir dir="./build/obj" />
36        <javac 
37            srcdir="./src" 
38            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
39            destdir="./build/obj" 
40            includeAntRuntime="false"
41            classpath="../../../core/java/build/i2p.jar:../../ministreaming/java/build/mstreaming.jar" >
42            <compilerarg line="${javac.compilerargs}" />
43        </javac>
44    </target>
45
46    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
47        <exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" >
48            <arg value="list" />
49            <arg value="changed" />
50            <arg value="." />
51        </exec>
52        <!-- \n in an attribute value generates an invalid manifest -->
53        <exec executable="tr" inputstring="${workspace.changes.j}" outputproperty="workspace.changes.j.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
54            <arg value="-s" />
55            <arg value="[:space:]" />
56            <arg value="," />
57        </exec>
58    </target>
59
60
61    <!-- The web classes are now in the war not the jar - they are not part of the API -->
62    <target name="jar" depends="builddep, compile, bundle-proxy, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
63        <!-- set if unset -->
64        <property name="workspace.changes.j.tr" value="" />
65        <jar destfile="./build/i2ptunnel.jar" basedir="./build/obj" includes="**/*.class" excludes="**/ui/*.class **/EditBean.class **/IndexBean.class" >
66            <manifest>
67                <attribute name="Main-Class" value="net.i2p.i2ptunnel.I2PTunnel" />
68                <attribute name="Class-Path" value="i2p.jar mstreaming.jar" />
69                <attribute name="Implementation-Version" value="${full.version}" />
70                <attribute name="Built-By" value="${build.built-by}" />
71                <attribute name="Build-Date" value="${build.timestamp}" />
72                <attribute name="Base-Revision" value="${workspace.version}" />
73                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
74            </manifest>
75        </jar>
76        <jar destfile="./build/temp-beans.jar" basedir="./build/obj" includes="**/ui/*.class **/EditBean.class **/IndexBean.class" />
77    </target>
78
79    <target name="jarUpToDate">
80        <uptodate property="jar.uptodate" targetfile="build/i2ptunnel.jar" >
81            <srcfiles dir= "build/obj" includes="**/*.class" />
82        </uptodate>
83        <condition property="shouldListChanges" >
84            <and>
85                <not>
86                    <isset property="jar.uptodate" />
87                </not>
88                <isset property="mtn.available" />
89            </and>
90        </condition>
91    </target>
92
93    <!-- Separate jar for general UI classes -->
94    <target name="uiJar" depends="jar, uiJarUpToDate, listChangedFiles" unless="uiJar.uptodate" >
95        <!-- set if unset -->
96        <property name="workspace.changes.j.tr" value="" />
97        <jar destfile="./build/i2ptunnel-ui.jar" basedir="./build/obj" includes="**/ui/*.class" >
98            <manifest>
99                <attribute name="Class-Path" value="i2p.jar mstreaming.jar i2ptunnel.jar" />
100                <attribute name="Implementation-Version" value="${full.version}" />
101                <attribute name="Built-By" value="${build.built-by}" />
102                <attribute name="Build-Date" value="${build.timestamp}" />
103                <attribute name="Base-Revision" value="${workspace.version}" />
104                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
105            </manifest>
106        </jar>
107    </target>
108
109    <target name="uiJarUpToDate">
110        <uptodate property="uiJar.uptodate" targetfile="build/i2ptunnel-ui.jar" >
111            <srcfiles dir= "build/obj" includes="**/ui/*.class" />
112        </uptodate>
113        <condition property="shouldListChanges" >
114            <and>
115                <not>
116                    <isset property="uiJar.uptodate" />
117                </not>
118                <isset property="mtn.available" />
119            </and>
120        </condition>
121    </target>
122
123    <!-- servlet translations go in the war, not the jar -->
124    <target name="bundle" depends="compile, precompilejsp" unless="no.bundle">
125        <!-- Update the messages_*.po files.
126             We need to supply the bat file for windows, and then change the fail property to true -->
127        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
128            <env key="JAVA_HOME" value="${java.home}" />
129            <arg value="./bundle-messages.sh" />
130        </exec>
131        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
132            <arg value="./bundle-messages.sh" />
133        </exec>
134                <!-- multi-lang is optional -->
135        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
136            <arg value="./bundle-messages.sh" />
137        </exec>
138    </target>
139
140    <target name="poupdate" depends="compile, precompilejsp">
141        <!-- Update the messages_*.po files. -->
142        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
143            <arg value="./bundle-messages.sh" />
144            <arg value="-p" />
145        </exec>
146        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
147            <arg value="./bundle-messages.sh" />
148            <arg value="-p" />
149        </exec>
150        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
151            <arg value="./bundle-messages.sh" />
152            <arg value="-p" />
153        </exec>
154    </target>
155
156    <!-- proxy error page translations go in the jar, not the war -->
157    <target name="bundle-proxy" unless="no.bundle">
158        <!-- Update the messages_*.po files.
159             We need to supply the bat file for windows, and then change the fail property to true -->
160        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
161            <env key="JAVA_HOME" value="${java.home}" />
162            <arg value="./bundle-messages-proxy.sh" />
163        </exec>
164        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
165            <arg value="./bundle-messages-proxy.sh" />
166        </exec>
167                <!-- multi-lang is optional -->
168        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
169            <arg value="./bundle-messages-proxy.sh" />
170        </exec>
171    </target>
172
173    <target name="extractProxyTags">
174        <java classname="net.i2p.util.TranslateReader" fork="true" failonerror="true">
175            <classpath>
176                <pathelement location="../../../build/i2p.jar" />
177            </classpath>
178            <arg value="tag" />
179            <arg value="../../../installer/resources/proxy/" />
180            <arg value="build/Proxy.java" />
181        </java>
182    </target>
183
184    <target name="poupdate-proxy" depends="extractProxyTags">
185        <!-- Update the messages_*.po files. -->
186        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
187            <arg value="./bundle-messages-proxy.sh" />
188            <arg value="-p" />
189        </exec>
190        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
191            <arg value="./bundle-messages-proxy.sh" />
192            <arg value="-p" />
193        </exec>
194        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
195            <arg value="./bundle-messages-proxy.sh" />
196            <arg value="-p" />
197        </exec>
198    </target>
199
200    <target name="listChangedFiles2" depends="warUpToDate" if="shouldListChanges2" >
201        <exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
202            <arg value="list" />
203            <arg value="changed" />
204            <arg value="../jsp" />
205        </exec>
206        <!-- \n in an attribute value generates an invalid manifest -->
207        <exec executable="tr" inputstring="${workspace.changes.w}" outputproperty="workspace.changes.w.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
208            <arg value="-s" />
209            <arg value="[:space:]" />
210            <arg value="," />
211        </exec>
212    </target>
213
214    <!-- The web classes are now in the war not the jar - they are not part of the API -->
215    <target name="war" depends="precompilejsp, bundle, warUpToDate, listChangedFiles2" unless="war.uptodate" > 
216        <!-- set if unset -->
217        <property name="workspace.changes.w.tr" value="" />
218        <copy todir="../jsp/WEB-INF/classes/net/i2p/i2ptunnel/ui">
219                <fileset dir="build/obj/net/i2p/i2ptunnel/ui" />
220        </copy>
221        <copy file="build/obj/net/i2p/i2ptunnel/web/EditBean.class" todir="../jsp/WEB-INF/classes/net/i2p/i2ptunnel/web" />
222        <copy file="build/obj/net/i2p/i2ptunnel/web/IndexBean.class" todir="../jsp/WEB-INF/classes/net/i2p/i2ptunnel/web" />
223        <war destfile="build/i2ptunnel.war" webxml="../jsp/web-out.xml"
224             basedir="../jsp/" excludes="web.xml, web-fragment.xml, web-out.xml, **/*.java, *.jsp">
225            <manifest>
226                <attribute name="Implementation-Version" value="${full.version}" />
227                <attribute name="Built-By" value="${build.built-by}" />
228                <attribute name="Build-Date" value="${build.timestamp}" />
229                <attribute name="Base-Revision" value="${workspace.version}" />
230                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
231            </manifest>
232        </war>
233    </target>
234
235    <target name="warUpToDate">
236        <uptodate property="war.uptodate" targetfile="build/i2ptunnel.war" >
237            <srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, **/*.java, *.jsp" />
238        </uptodate>
239        <condition property="shouldListChanges2" >
240            <and>
241                <not>
242                    <isset property="war.uptodate" />
243                </not>
244                <isset property="mtn.available" />
245            </and>
246        </condition>
247    </target>
248
249    <target name="precompilejsp" depends="jar" unless="precompilejsp.uptodate">
250        <delete dir="../jsp/WEB-INF/" />
251        <delete file="../jsp/web-fragment.xml" />
252        <delete file="../jsp/web-out.xml" />
253        <mkdir dir="../jsp/WEB-INF/" />
254        <mkdir dir="../jsp/WEB-INF/classes" />
255        <!-- there are various jspc ant tasks, but they all seem a bit flakey -->
256        <java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
257            <classpath>
258                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
259                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
260                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
261                <pathelement location="../../jetty/jettylib/commons-el.jar" />
262                <pathelement location="${ant.home}/lib/ant.jar" />
263                <pathelement location="build/i2ptunnel.jar" />
264                <pathelement location="build/temp-beans.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.i2ptunnel.jsp" />
272            <arg value="-webinc" />
273            <arg value="../jsp/web-fragment.xml" />
274            <arg value="-webapp" />
275            <arg value="../jsp/" />
276        </java>
277        <javac debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
278               includeAntRuntime="false"
279               destdir="../jsp/WEB-INF/classes/" srcdir="../jsp/WEB-INF/classes" includes="**/*.java">
280            <compilerarg line="${javac.compilerargs}" />
281            <classpath>
282                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
283                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
284                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
285                <pathelement location="../../jetty/jettylib/commons-el.jar" />
286                <pathelement location="build/i2ptunnel.jar" />
287                <pathelement location="build/temp-beans.jar" />
288                <pathelement location="../../../core/java/build/i2p.jar" />
289            </classpath>
290        </javac>
291        <copy file="../jsp/web.xml" tofile="../jsp/web-out.xml" />
292        <loadfile property="jspc.web.fragment" srcfile="../jsp/web-fragment.xml" />
293        <replace file="../jsp/web-out.xml">
294            <replacefilter token="&lt;!-- precompiled servlets --&gt;" value="${jspc.web.fragment}" />
295        </replace>
296    </target>
297
298    <uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
299        <srcfiles dir= "../jsp" includes="*.jsp, *.html, web.xml"/>
300        <srcfiles dir= "src/net/i2p/i2ptunnel/web" includes="*.java"/>
301    </uptodate>
302
303    <target name="javadoc">
304        <mkdir dir="./build" />
305        <mkdir dir="./build/javadoc" />
306        <javadoc 
307            sourcepath="./src:../../../core/java/src:../../ministreaming/java/src" destdir="./build/javadoc" 
308            packagenames="*" 
309            use="true" 
310            splitindex="true" 
311            windowtitle="I2PTunnel" />
312    </target>
313
314    <target name="compileTest">
315        <mkdir dir="./build" />
316        <mkdir dir="./build/obj" />
317        <!-- We need the ant runtime, as it includes junit -->
318        <javac srcdir="./src:./test/junit" debug="true" source="${javac.version}" target="${javac.version}"
319               includeAntRuntime="true"
320               deprecation="on" destdir="./build/obj" >
321            <compilerarg line="${javac.compilerargs}" />
322            <classpath>
323                <pathelement location="../../../core/java/build/i2p.jar" />
324                <pathelement location="../../ministreaming/java/build/mstreaming.jar" />
325            </classpath>
326        </javac>
327    </target>
328    <target name="test" depends="clean, compileTest">
329        <junit printsummary="on" fork="yes">
330            <classpath>
331                <pathelement path="${classpath}" />
332                <pathelement location="./build/obj" />
333                <pathelement location="../../../core/java/build/i2p.jar" />
334            </classpath>
335            <batchtest>
336                <fileset dir="./test/junit/">
337                    <include name="**/*Test.java" />
338                </fileset>
339            </batchtest>
340            <formatter type="xml"/>
341        </junit>
342        <mkdir dir="../../../reports/" />
343        <mkdir dir="../../../reports/i2ptunnel/" />
344        <mkdir dir="../../../reports/i2ptunnel/junit/" />
345        <delete>
346            <fileset dir="../../../reports/i2ptunnel/junit">
347                <include name="TEST-*.xml"/>
348            </fileset>
349        </delete>
350        <copy todir="../../../reports/i2ptunnel/junit">
351            <fileset dir=".">
352                <include name="TEST-*.xml"/>
353            </fileset>
354        </copy>
355        <delete>
356            <fileset dir=".">
357                <include name="TEST-*.xml"/>
358            </fileset>
359        </delete>
360    </target>
361
362    <target name="clean">
363        <delete dir="./build" />
364        <delete dir="../jsp/WEB-INF/" />
365        <delete file="../jsp/web-fragment.xml" />
366        <delete file="../jsp/web-out.xml" />
367    </target>
368    <target name="cleandep" depends="clean">
369    </target>
370    <target name="distclean" depends="clean">
371    </target>
372</project>
Note: See TracBrowser for help on using the repository browser.