source: apps/i2psnark/java/build.xml @ 1fea327

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

more jar manifest attributes

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