source: apps/i2ptunnel/java/build.xml @ 43ec87e

Last change on this file since 43ec87e was 43ec87e, checked in by zzz <zzz@…>, 9 years ago
  • i2ptunnel: Move bean classes from the jar to the war. External usage was deprecated about a year ago. This will break old seedless plugins.
  • Property mode set to 100644
File size: 12.5 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    <property name="javac.compilerargs" value="" />
25    <property name="require.gettext" value="true" />
26
27    <target name="compile" depends="depend">
28        <mkdir dir="./build" />
29        <mkdir dir="./build/obj" />
30        <javac 
31            srcdir="./src" 
32            debug="true" deprecation="on" source="1.5" target="1.5" 
33            destdir="./build/obj" 
34            includeAntRuntime="false"
35            classpath="../../../core/java/build/i2p.jar:../../ministreaming/java/build/mstreaming.jar" >
36            <compilerarg line="${javac.compilerargs}" />
37        </javac>
38    </target>
39
40    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
41        <exec executable="mtn" outputproperty="workspace.changes.j" errorproperty="mtn.error2" failifexecutionfails="false" >
42            <arg value="list" />
43            <arg value="changed" />
44            <arg value="." />
45        </exec>
46        <!-- \n in an attribute value generates an invalid manifest -->
47        <exec executable="tr" inputstring="${workspace.changes.j}" outputproperty="workspace.changes.j.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
48            <arg value="-s" />
49            <arg value="[:space:]" />
50            <arg value="," />
51        </exec>
52    </target>
53
54
55    <!-- The web classes are now in the war not the jar - they are not part of the API -->
56    <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
57        <!-- set if unset -->
58        <property name="workspace.changes.j.tr" value="" />
59        <jar destfile="./build/i2ptunnel.jar" basedir="./build/obj" includes="**/*.class" excludes="**/EditBean.class **/IndexBean.class" >
60            <manifest>
61                <attribute name="Main-Class" value="net.i2p.i2ptunnel.I2PTunnel" />
62                <attribute name="Class-Path" value="i2p.jar mstreaming.jar" />
63                <attribute name="Build-Date" value="${build.timestamp}" />
64                <attribute name="Base-Revision" value="${workspace.version}" />
65                <attribute name="Workspace-Changes" value="${workspace.changes.j.tr}" />
66            </manifest>
67        </jar>
68        <jar destfile="./build/temp-beans.jar" basedir="./build/obj" includes="**/EditBean.class **/IndexBean.class" />
69    </target>
70
71    <target name="jarUpToDate">
72        <uptodate property="jar.uptodate" targetfile="build/i2ptunnel.jar" >
73            <srcfiles dir= "build/obj" includes="**/*.class" />
74        </uptodate>
75        <condition property="shouldListChanges" >
76            <and>
77                <not>
78                    <isset property="jar.uptodate" />
79                </not>
80                <isset property="mtn.available" />
81            </and>
82        </condition>
83    </target>
84
85    <target name="bundle" depends="compile, precompilejsp">
86        <!-- Update the messages_*.po files.
87             We need to supply the bat file for windows, and then change the fail property to true -->
88        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
89            <arg value="./bundle-messages.sh" />
90        </exec>
91        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
92            <arg value="./bundle-messages.sh" />
93        </exec>
94                <!-- multi-lang is optional -->
95        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
96            <arg value="./bundle-messages.sh" />
97        </exec>
98    </target>
99
100    <target name="poupdate" depends="compile, precompilejsp">
101        <!-- Update the messages_*.po files. -->
102        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
103            <arg value="./bundle-messages.sh" />
104            <arg value="-p" />
105        </exec>
106        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
107            <arg value="./bundle-messages.sh" />
108            <arg value="-p" />
109        </exec>
110        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
111            <arg value="./bundle-messages.sh" />
112            <arg value="-p" />
113        </exec>
114    </target>
115
116    <target name="listChangedFiles2" depends="warUpToDate" if="shouldListChanges2" >
117        <exec executable="mtn" outputproperty="workspace.changes.w" errorproperty="mtn.error2" failifexecutionfails="false" >
118            <arg value="list" />
119            <arg value="changed" />
120            <arg value="../jsp" />
121        </exec>
122        <!-- \n in an attribute value generates an invalid manifest -->
123        <exec executable="tr" inputstring="${workspace.changes.w}" outputproperty="workspace.changes.w.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
124            <arg value="-s" />
125            <arg value="[:space:]" />
126            <arg value="," />
127        </exec>
128    </target>
129
130    <!-- The web classes are now in the war not the jar - they are not part of the API -->
131    <target name="war" depends="precompilejsp, bundle, warUpToDate, listChangedFiles2" unless="war.uptodate" > 
132        <!-- set if unset -->
133        <property name="workspace.changes.w.tr" value="" />
134        <copy file="build/obj/net/i2p/i2ptunnel/web/EditBean.class" todir="../jsp/WEB-INF/classes/net/i2p/i2ptunnel/web" />
135        <copy file="build/obj/net/i2p/i2ptunnel/web/IndexBean.class" todir="../jsp/WEB-INF/classes/net/i2p/i2ptunnel/web" />
136        <war destfile="build/i2ptunnel.war" webxml="../jsp/web-out.xml"
137             basedir="../jsp/" excludes="web.xml, web-fragment.xml, web-out.xml, **/*.java, *.jsp">
138            <manifest>
139                <attribute name="Build-Date" value="${build.timestamp}" />
140                <attribute name="Base-Revision" value="${workspace.version}" />
141                <attribute name="Workspace-Changes" value="${workspace.changes.w.tr}" />
142            </manifest>
143        </war>
144    </target>
145
146    <target name="warUpToDate">
147        <uptodate property="war.uptodate" targetfile="build/i2ptunnel.war" >
148            <srcfiles dir= "../jsp" excludes="web.xml, web-fragment.xml, **/*.java, *.jsp" />
149        </uptodate>
150        <condition property="shouldListChanges2" >
151            <and>
152                <not>
153                    <isset property="war.uptodate" />
154                </not>
155                <isset property="mtn.available" />
156            </and>
157        </condition>
158    </target>
159
160    <target name="precompilejsp" depends="jar" unless="precompilejsp.uptodate">
161        <delete dir="../jsp/WEB-INF/" />
162        <delete file="../jsp/web-fragment.xml" />
163        <delete file="../jsp/web-out.xml" />
164        <mkdir dir="../jsp/WEB-INF/" />
165        <mkdir dir="../jsp/WEB-INF/classes" />
166        <!-- there are various jspc ant tasks, but they all seem a bit flakey -->
167        <java classname="org.apache.jasper.JspC" fork="true" failonerror="true">
168            <classpath>
169                <pathelement location="../../jetty/jettylib/jasper-compiler.jar" />
170                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
171                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
172                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
173                <pathelement location="../../jetty/jettylib/commons-el.jar" />
174                <pathelement location="../../jetty/jettylib/jsp-api.jar" />
175                <pathelement location="../../jetty/jettylib/ant.jar" />
176                <pathelement location="build/i2ptunnel.jar" />
177                <pathelement location="build/temp-beans.jar" />
178            </classpath>
179            <arg value="-d" />
180            <arg value="../jsp/WEB-INF/classes" />
181            <arg value="-v" />
182            <arg value="-p" />
183            <arg value="net.i2p.i2ptunnel.jsp" />
184            <arg value="-webinc" />
185            <arg value="../jsp/web-fragment.xml" />
186            <arg value="-webapp" />
187            <arg value="../jsp/" />
188        </java>
189        <javac debug="true" deprecation="on" source="1.5" target="1.5" 
190               includeAntRuntime="false"
191               destdir="../jsp/WEB-INF/classes/" srcdir="../jsp/WEB-INF/classes" includes="**/*.java">
192            <compilerarg line="${javac.compilerargs}" />
193            <classpath>
194                <pathelement location="../../jetty/jettylib/jasper-runtime.jar" />
195                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
196                <pathelement location="../../jetty/jettylib/commons-logging.jar" />
197                <pathelement location="../../jetty/jettylib/commons-el.jar" />
198                <pathelement location="../../jetty/jettylib/jsp-api.jar" />
199                <pathelement location="build/i2ptunnel.jar" />
200                <pathelement location="build/temp-beans.jar" />
201            </classpath>
202        </javac>
203        <copy file="../jsp/web.xml" tofile="../jsp/web-out.xml" />
204        <loadfile property="jspc.web.fragment" srcfile="../jsp/web-fragment.xml" />
205        <replace file="../jsp/web-out.xml">
206            <replacefilter token="&lt;!-- precompiled servlets --&gt;" value="${jspc.web.fragment}" />
207        </replace>
208    </target>
209
210    <uptodate property="precompilejsp.uptodate" targetfile="../jsp/web-out.xml">
211        <srcfiles dir= "../jsp" includes="*.jsp, *.html, web.xml"/>
212    </uptodate>
213
214    <target name="javadoc">
215        <mkdir dir="./build" />
216        <mkdir dir="./build/javadoc" />
217        <javadoc 
218            sourcepath="./src:../../../core/java/src:../../ministreaming/java/src" destdir="./build/javadoc" 
219            packagenames="*" 
220            use="true" 
221            splitindex="true" 
222            windowtitle="I2PTunnel" />
223    </target>
224
225    <target name="compileTest">
226        <mkdir dir="./build" />
227        <mkdir dir="./build/obj" />
228        <!-- We need the ant runtime, as it includes junit -->
229        <javac srcdir="./src:./test" debug="true" source="1.5" target="1.5"
230               includeAntRuntime="true"
231               deprecation="on" destdir="./build/obj" >
232            <compilerarg line="${javac.compilerargs}" />
233            <classpath>
234                <pathelement location="../../../core/java/build/i2p.jar" />
235                <pathelement location="../../ministreaming/java/build/mstreaming.jar" />
236            </classpath>
237        </javac>
238    </target>
239    <target name="test" depends="clean, compileTest">
240        <junit printsummary="on" fork="yes">
241            <classpath>
242                <pathelement path="${classpath}" />
243                <pathelement location="./build/obj" />
244                <pathelement location="../../../core/java/build/i2p.jar" />
245            </classpath>
246            <batchtest>
247                <fileset dir="./test/">
248                    <include name="**/*Test.java" />
249                </fileset>
250            </batchtest>
251            <formatter type="xml"/>
252        </junit>
253        <mkdir dir="../../../reports/" />
254        <mkdir dir="../../../reports/i2ptunnel/" />
255        <mkdir dir="../../../reports/i2ptunnel/junit/" />
256        <delete>
257            <fileset dir="../../../reports/i2ptunnel/junit">
258                <include name="TEST-*.xml"/>
259            </fileset>
260        </delete>
261        <copy todir="../../../reports/i2ptunnel/junit">
262            <fileset dir=".">
263                <include name="TEST-*.xml"/>
264            </fileset>
265        </copy>
266        <delete>
267            <fileset dir=".">
268                <include name="TEST-*.xml"/>
269            </fileset>
270        </delete>
271    </target>
272
273    <target name="clean">
274        <delete dir="./build" />
275        <delete dir="../jsp/WEB-INF/" />
276        <delete file="../jsp/web-fragment.xml" />
277        <delete file="../jsp/web-out.xml" />
278    </target>
279    <target name="cleandep" depends="clean">
280    </target>
281    <target name="distclean" depends="clean">
282    </target>
283</project>
Note: See TracBrowser for help on using the repository browser.