source: apps/i2ptunnel/java/build.xml @ 6623616

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