source: apps/i2ptunnel/java/build.xml @ 7ae1483

Last change on this file since 7ae1483 was 7ae1483, checked in by zzz <zzz@…>, 4 years ago

Fixes for building with libgetopt-java

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