source: apps/i2psnark/java/build.xml @ e68182a

Last change on this file since e68182a was e68182a, checked in by zzz <zzz@…>, 3 years ago

Build: Provide option to prevent Class-Path in manifests (ticket #2317)

  • Property mode set to 100644
File size: 17.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="i2psnark">
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                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
22                <!-- jsp-api.jar only present for debian builds -->
23                <pathelement location="../../jetty/jettylib/jsp-api.jar" />
24            </classpath>
25        </depend>
26    </target>
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.7" />
31    <property name="require.gettext" value="true" />
32    <property name="manifest.classpath.name" value="Class-Path" />
33
34    <condition property="no.bundle">
35        <isfalse value="${require.gettext}" />
36    </condition>
37
38    <target name="compile" depends="depend">
39        <mkdir dir="./build" />
40        <mkdir dir="./build/obj" />
41        <javac 
42            srcdir="./src" 
43            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
44            destdir="./build/obj" 
45            includeAntRuntime="false" >
46            <compilerarg line="${javac.compilerargs}" />
47            <classpath>
48                <pathelement location="../../../core/java/build/i2p.jar" />
49                <!-- gnu-getopt.jar only present for debian builds -->
50                <pathelement location="../../../core/java/build/gnu-getopt.jar" />
51                <pathelement location="../../ministreaming/java/build/mstreaming.jar" />
52                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
53                <!-- jsp-api.jar only present for debian builds -->
54                <pathelement location="../../jetty/jettylib/jsp-api.jar" />
55                <!-- following jars only for standalone builds -->
56                <pathelement location="../../jetty/jettylib/jetty-i2p.jar" />
57                <pathelement location="../../systray/java/build/systray.jar" />
58                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
59                <pathelement location="../../jetty/jettylib/jetty-util.jar" />
60            </classpath>
61        </javac>
62    </target>
63
64    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
65        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
66            <arg value="list" />
67            <arg value="changed" />
68            <arg value=".." />
69        </exec>
70        <!-- \n in an attribute value generates an invalid manifest -->
71        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
72            <arg value="-s" />
73            <arg value="[:space:]" />
74            <arg value="," />
75        </exec>
76    </target>
77
78    <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
79        <!-- set if unset -->
80        <property name="workspace.changes.tr" value="" />
81        <jar destfile="./build/i2psnark.jar" basedir="./build/obj" includes="**/*.class" excludes="**/web/* **/messages_*.class, **/standalone/*">
82            <manifest>
83                <attribute name="Main-Class" value="org.klomp.snark.CommandLine" />
84                <attribute name="${manifest.classpath.name}" value="i2p.jar mstreaming.jar streaming.jar" />
85                <attribute name="Implementation-Version" value="${full.version}" />
86                <attribute name="Built-By" value="${build.built-by}" />
87                <attribute name="Build-Date" value="${build.timestamp}" />
88                <attribute name="Base-Revision" value="${workspace.version}" />
89                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
90                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
91                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
92            </manifest>
93        </jar>
94    </target>
95
96    <target name="jarUpToDate">
97        <uptodate property="jar.uptodate" targetfile="build/i2psnark.jar" >
98            <srcfiles dir= "build/obj" includes="**/*.class" excludes="**/web/* **/messages_*.class" />
99        </uptodate>
100        <condition property="shouldListChanges" >
101            <and>
102                <not>
103                    <isset property="jar.uptodate" />
104                </not>
105                <not>
106                    <isset property="war.uptodate" />
107                </not>
108                <isset property="mtn.available" />
109            </and>
110        </condition>
111    </target>   
112
113    <!-- Ideally we would include
114      -  only include the servlet, everything else is in the jar.
115      -  However, the wrapper.config classpath in existing installs
116      -  does not include i2psnark.jar.
117      -  So we must continue to duplicate everything in the war.
118          <classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
119     -->
120    <target name="war" depends="jar, bundle, warUpToDate, listChangedFiles" unless="war.uptodate" > 
121        <!-- set if unset -->
122        <property name="workspace.changes.tr" value="" />
123        <copy todir="build/resources/.resources" >
124            <fileset dir="../resources/" />
125        </copy>
126        <!-- mime.properties must be in with the classes -->
127        <copy file="../mime.properties" todir="build/obj/org/klomp/snark/web" />
128        <war destfile="../i2psnark.war" webxml="../web.xml" >
129          <!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
130          <classes dir="./build/obj" includes="**/web/*" />
131            <fileset dir="build/resources/" />
132            <manifest>
133                <attribute name="Implementation-Version" value="${full.version}" />
134                <attribute name="Built-By" value="${build.built-by}" />
135                <attribute name="Build-Date" value="${build.timestamp}" />
136                <attribute name="Base-Revision" value="${workspace.version}" />
137                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
138                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
139                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
140            </manifest>
141        </war>
142    </target>
143
144    <target name="warUpToDate">
145        <uptodate property="war.uptodate" targetfile="../i2psnark.war" >
146            <srcfiles dir= "." includes="build/obj/org/klomp/snark/web/*.class ../resources/**/* ../web.xml" />
147        </uptodate>
148    </target>
149
150    <target name="bundle" depends="compile" unless="no.bundle">
151        <mkdir dir="build/messages-src" />
152        <!-- Update the messages_*.po files.
153             We need to supply the bat file for windows, and then change the fail property to true -->
154        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
155            <env key="JAVA_HOME" value="${java.home}" />
156            <arg value="./bundle-messages.sh" />
157        </exec>
158        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
159            <arg value="./bundle-messages.sh" />
160        </exec>
161        <!-- multi-lang is optional -->
162        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
163            <arg value="./bundle-messages.sh" />
164        </exec>
165        <javac source="${javac.version}" target="${javac.version}" 
166               includeAntRuntime="false"
167               srcdir="build/messages-src" destdir="build/obj">
168            <compilerarg line="${javac.compilerargs}" />
169        </javac>
170    </target>
171
172    <target name="poupdate" depends="builddep, compile">
173        <!-- Update the messages_*.po files.  -->
174        <!-- set if unset -->
175        <property name="lg2" value="" />
176        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
177            <env key="LG2" value="${lg2}" />
178            <arg value="./bundle-messages.sh" />
179            <arg value="-p" />
180        </exec>
181        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
182            <env key="LG2" value="${lg2}" />
183            <arg value="./bundle-messages.sh" />
184            <arg value="-p" />
185        </exec>
186        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
187            <env key="LG2" value="${lg2}" />
188            <arg value="./bundle-messages.sh" />
189            <arg value="-p" />
190        </exec>
191    </target>
192
193    <target name="standalone" depends="standalone_prep">
194        <zip destfile="i2psnark-standalone.zip">
195          <zipfileset dir="./dist/" prefix="i2psnark/" />
196        </zip>
197    </target>
198
199    <!-- make a fat jar for standalone -->
200    <target name="standalone_jar" depends="war">
201      <!-- set if unset -->
202      <property name="workspace.changes.tr" value="" />
203      <jar destfile="build/i2psnark-standalone.jar">
204        <fileset dir="build/obj" includes="**/standalone/*.class" />
205        <zipfileset src="build/i2psnark.jar" />
206        <zipfileset src="../../../core/java/build/i2p.jar" />
207      <!-- without this we get a warning about 'no JSP support' but that's it
208        <zipfileset src="../../jetty/jettylib/jasper-runtime.jar"  />
209       -->
210        <zipfileset src="../../jetty/jettylib/javax.servlet.jar" />
211        <zipfileset src="../../jetty/jettylib/jetty-continuation.jar" />
212        <zipfileset src="../../jetty/jettylib/jetty-deploy.jar" />
213        <zipfileset src="../../jetty/jettylib/jetty-http.jar" />
214        <zipfileset src="../../jetty/jettylib/jetty-i2p.jar" />
215        <zipfileset src="../../jetty/jettylib/jetty-io.jar" />
216        <zipfileset src="../../jetty/jettylib/jetty-security.jar"  />
217        <zipfileset src="../../jetty/jettylib/jetty-servlet.jar" />
218        <zipfileset src="../../jetty/jettylib/jetty-util.jar" />
219        <zipfileset src="../../jetty/jettylib/jetty-webapp.jar" />
220        <zipfileset src="../../jetty/jettylib/jetty-xml.jar" />
221        <zipfileset src="../../jetty/jettylib/org.mortbay.jetty.jar"  />
222        <zipfileset src="../../ministreaming/java/build/mstreaming.jar" />
223        <zipfileset src="../../streaming/java/build/streaming.jar" />
224        <zipfileset src="../../systray/java/build/systray.jar" />
225        <!-- Countries translations. The i2psnark translations are in the war but it's easier to put these here -->
226        <!-- 300KB just to translate "Brazil", but why not... -->
227      <!--
228        <fileset dir="../../routerconsole/java/build/obj" includes="net/i2p/router/countries/*.class" />
229       -->
230        <manifest>
231            <attribute name="Main-Class" value="org.klomp.snark.standalone.RunStandalone"/>
232            <attribute name="Implementation-Version" value="${full.version}" />
233            <attribute name="Built-By" value="${build.built-by}" />
234            <attribute name="Build-Date" value="${build.timestamp}" />
235            <attribute name="Base-Revision" value="${workspace.version}" />
236            <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
237            <!-- this is so Jetty will report its version correctly -->
238            <section name="org/eclipse/jetty/server/" >
239                <attribute name="Implementation-Vendor" value="Eclipse.org - Jetty" />
240                <attribute name="Implementation-Version" value="8.1.17.v20150415" />
241            </section>
242        </manifest>
243      </jar>
244    </target>
245
246    <!-- add css, image, and js files for standalone snark to the war -->
247    <target name="standalone_war" depends="war">
248        <mkdir dir="build/standalone-resources/.resources/themes/snark" />
249        <copy todir="build/standalone-resources/.resources/themes/snark" >
250            <fileset dir="../../../installer/resources/themes/snark/" />
251        </copy>
252
253        <replace dir="build/standalone-resources/.resources/themes/snark"
254            summary="true"
255            token="url(/themes/console/classic/images/"
256            value="url(/i2psnark/.resources/themes/snark/classic/images/" >
257            <include name="**/*.css" />
258        </replace>
259        <replace dir="build/standalone-resources/.resources/themes/snark"
260            summary="true"
261            token="url(/themes/console/dark/images/"
262            value="url(/i2psnark/.resources/themes/snark/dark/images/" >
263            <include name="**/*.css" />
264        </replace>
265        <replace dir="build/standalone-resources/.resources/themes/snark"
266            summary="true"
267            token="url(../../console/light/images/"
268            value="url(/i2psnark/.resources/themes/snark/light/images/" >
269            <include name="**/*.css" />
270        </replace>
271        <replace dir="build/standalone-resources/.resources/themes/snark"
272            summary="true"
273            token="url(/themes/console/light/images/"
274            value="url(/i2psnark/.resources/themes/snark/light/images/" >
275            <include name="**/*.css" />
276        </replace>
277        <replace dir="build/standalone-resources/.resources/themes/snark"
278            summary="true"
279            token="url(/themes/console/images/transparent.gif"
280            value="url(/i2psnark/.resources/themes/snark/ubergine/images/transparent.gif" >
281            <include name="**/*.css" />
282        </replace>
283        <replace dir="build/standalone-resources/.resources/themes/snark"
284            summary="true"
285            token="url(/themes/console/images/info/"
286            value="url(/i2psnark/.resources/themes/snark/ubergine/images/" >
287            <include name="**/*.css" />
288        </replace>
289
290        <!-- Rather than pulling in all the console theme images, let's just specify the ones we need -->
291        <copy file="../../../installer/resources/themes/console/images/transparent.gif"
292              todir="build/standalone-resources/.resources/themes/snark/ubergine/images" />
293        <copy file="../../../installer/resources/themes/console/dark/images/header.png"
294              todir="build/standalone-resources/.resources/themes/snark/dark/images" />
295        <copy file="../../../installer/resources/themes/console/light/images/header.png"
296              todir="build/standalone-resources/.resources/themes/snark/light/images" />
297        <copy file="../../../installer/resources/themes/console/dark/images/camotile2.png"
298              todir="build/standalone-resources/.resources/themes/snark/dark/images" />
299        <copy file="../../../installer/resources/themes/console/images/info/errortriangle.png"
300              todir="build/standalone-resources/.resources/themes/snark/ubergine/images" />
301        <copy file="../../../installer/resources/themes/console/classic/images/bg0.png"
302              todir="build/standalone-resources/.resources/themes/snark/classic/images" />
303
304        <mkdir dir="build/standalone-resources/.resources/js" />
305        <copy file="../../routerconsole/jsp/js/ajax.js" todir="build/standalone-resources/.resources/js" />
306
307        <zip destfile="../i2psnark.war" update="true" duplicate="preserve" >
308            <fileset dir="build/standalone-resources" />
309        </zip>
310    </target>
311
312    <target name="standalone_prep" depends="standalone_jar, standalone_war">
313        <delete dir="./dist" />
314        <mkdir dir="./dist" />
315        <copy file="../launch-i2psnark" todir="./dist/" />
316        <copy file="../launch-i2psnark.bat" todir="./dist/" />
317        <mkdir dir="./dist/contexts" />
318        <copy file="../standalone-context.xml" tofile="./dist/contexts/context.xml" />
319        <mkdir dir="./dist/docroot" />
320        <copy file="../standalone-index.html" tofile="./dist/docroot/index.html" />
321        <mkdir dir="./dist/webapps" />
322        <copy file="../i2psnark.war" tofile="./dist/webapps/i2psnark.war" />
323        <copy file="../jetty-i2psnark.xml" tofile="./dist/jetty-i2psnark.xml" />
324        <copy file="../i2psnark-appctx.config" tofile="./dist/i2psnark-appctx.config" />
325        <copy file="./build/i2psnark-standalone.jar" tofile="./dist/i2psnark.jar" />
326        <copy file="../readme-standalone.txt" tofile="./dist/readme.txt" />
327        <!-- temp so announces work -->
328        <copy file="../../../installer/resources/hosts.txt" tofile="./dist/hosts.txt" />
329        <copy todir="./dist/licenses" >
330            <fileset dir="../../../licenses" includes="LICENSE-GPLv2.txt, ABOUT-Jetty.html" />
331        </copy>
332        <mkdir dir="./dist/logs" />
333    </target>
334
335    <target name="clean">
336        <delete dir="./build" />
337        <delete file="../i2psnark.war" />
338        <delete file="./i2psnark-standalone.zip" />
339        <delete dir="./dist" />
340    </target>
341    <target name="cleandep" depends="clean">
342    </target>
343    <target name="distclean" depends="clean">
344    </target>
345</project>
Note: See TracBrowser for help on using the repository browser.