source: apps/i2psnark/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: 9.9 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            </classpath>
54        </javac>
55    </target>
56
57    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
58        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
59            <arg value="list" />
60            <arg value="changed" />
61            <arg value=".." />
62        </exec>
63        <!-- \n in an attribute value generates an invalid manifest -->
64        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
65            <arg value="-s" />
66            <arg value="[:space:]" />
67            <arg value="," />
68        </exec>
69    </target>
70
71    <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
72        <!-- set if unset -->
73        <property name="workspace.changes.tr" value="" />
74        <jar destfile="./build/i2psnark.jar" basedir="./build/obj" includes="**/*.class" excludes="**/web/* **/messages_*.class">
75            <manifest>
76                <attribute name="Main-Class" value="org.klomp.snark.CommandLine" />
77                <attribute name="Class-Path" value="i2p.jar mstreaming.jar streaming.jar" />
78                <attribute name="Implementation-Version" value="${full.version}" />
79                <attribute name="Built-By" value="${build.built-by}" />
80                <attribute name="Build-Date" value="${build.timestamp}" />
81                <attribute name="Base-Revision" value="${workspace.version}" />
82                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
83            </manifest>
84        </jar>
85    </target>   
86   
87    <target name="jarUpToDate">
88        <uptodate property="jar.uptodate" targetfile="build/i2psnark.jar" >
89            <srcfiles dir= "build/obj" includes="**/*.class" excludes="**/web/* **/messages_*.class" />
90        </uptodate>
91        <condition property="shouldListChanges" >
92            <and>
93                <not>
94                    <isset property="jar.uptodate" />
95                </not>
96                <not>
97                    <isset property="war.uptodate" />
98                </not>
99                <isset property="mtn.available" />
100            </and>
101        </condition>
102    </target>   
103
104    <!-- Ideally we would include
105      -  only include the servlet, everything else is in the jar.
106      -  However, the wrapper.config classpath in existing installs
107      -  does not include i2psnark.jar.
108      -  So we must continue to duplicate everything in the war.
109          <classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
110     -->
111    <target name="war" depends="jar, bundle, warUpToDate, listChangedFiles" unless="war.uptodate" > 
112        <!-- set if unset -->
113        <property name="workspace.changes.tr" value="" />
114        <copy todir="build/resources/.resources" >
115            <fileset dir="../resources/" />
116        </copy>
117        <!-- mime.properties must be in with the classes -->
118        <copy file="../mime.properties" todir="build/obj/org/klomp/snark/web" />
119        <war destfile="../i2psnark.war" webxml="../web.xml" >
120          <!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
121          <classes dir="./build/obj" includes="**/web/*" />
122            <fileset dir="build/resources/" />
123            <manifest>
124                <attribute name="Implementation-Version" value="${full.version}" />
125                <attribute name="Built-By" value="${build.built-by}" />
126                <attribute name="Build-Date" value="${build.timestamp}" />
127                <attribute name="Base-Revision" value="${workspace.version}" />
128                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
129            </manifest>
130        </war>
131    </target>
132   
133    <target name="warUpToDate">
134        <uptodate property="war.uptodate" targetfile="../i2psnark.war" >
135            <srcfiles dir= "." includes="build/obj/org/klomp/snark/web/*.class ../resources/**/* ../web.xml" />
136        </uptodate>
137    </target>
138   
139    <target name="bundle" depends="compile" unless="no.bundle">
140        <!-- Update the messages_*.po files.
141             We need to supply the bat file for windows, and then change the fail property to true -->
142        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="${require.gettext}" >
143            <env key="JAVA_HOME" value="${java.home}" />
144            <arg value="./bundle-messages.sh" />
145        </exec>
146        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="${require.gettext}" >
147            <arg value="./bundle-messages.sh" />
148        </exec>
149                <!-- multi-lang is optional -->
150        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
151            <arg value="./bundle-messages.sh" />
152        </exec>
153    </target>
154
155    <target name="poupdate" depends="builddep, compile">
156        <!-- Update the messages_*.po files.  -->
157        <exec executable="sh" osfamily="unix" failifexecutionfails="true" failonerror="true" >
158            <arg value="./bundle-messages.sh" />
159            <arg value="-p" />
160        </exec>
161        <exec executable="sh" osfamily="mac" failifexecutionfails="true" failonerror="true" >
162            <arg value="./bundle-messages.sh" />
163            <arg value="-p" />
164        </exec>
165        <exec executable="sh" osfamily="windows" failifexecutionfails="true" failonerror="true" >
166            <arg value="./bundle-messages.sh" />
167            <arg value="-p" />
168        </exec>
169    </target>
170
171    <target name="standalone" depends="standalone_prep">
172        <zip destfile="i2psnark-standalone.zip">
173          <zipfileset dir="./dist/" prefix="i2psnark/" />
174        </zip>
175    </target>
176    <target name="standalone_prep" depends="war">
177        <delete dir="./dist" />
178        <mkdir dir="./dist" />
179        <copy file="../launch-i2psnark" todir="./dist/" />
180        <mkdir dir="./dist/webapps" />
181        <copy file="../i2psnark.war" tofile="./dist/webapps/i2psnark.war" />
182        <mkdir dir="./dist/lib" />
183        <copy file="./build/i2psnark.jar" tofile="./dist/lib/i2psnark.jar" />
184        <copy file="../../../core/java/build/i2p.jar" tofile="./dist/lib/i2p.jar" />
185        <copy file="../../jetty/jettylib/commons-el.jar" tofile="./dist/lib/commons-el.jar" />
186        <copy file="../../jetty/jettylib/commons-logging.jar" tofile="./dist/lib/commons-logging.jar" />
187        <copy file="../../jetty/jettylib/javax.servlet.jar" tofile="./dist/lib/javax.servlet.jar" />
188        <copy file="../../jetty/jettylib/org.mortbay.jetty.jar" tofile="./dist/lib/org.mortbay.jetty.jar" />
189        <copy file="../../jetty/jettylib/jasper-runtime.jar" tofile="./dist/lib/jasper-runtime.jar" />
190        <copy file="../../ministreaming/java/build/mstreaming.jar" tofile="./dist/lib/mstreaming.jar" />
191        <copy file="../../streaming/java/build/streaming.jar" tofile="./dist/lib/streaming.jar" />
192        <copy file="../jetty-i2psnark.xml" tofile="./dist/jetty-i2psnark.xml" />
193        <copy file="../readme-standalone.txt" tofile="./dist/readme.txt" />
194        <mkdir dir="./dist/logs" />
195
196        <zip destfile="i2psnark-standalone.zip">
197         <zipfileset dir="./dist/" prefix="i2psnark/" />
198        </zip>
199    </target>
200
201    <target name="clean">
202        <delete dir="./build" />
203        <delete file="../i2psnark.war" />
204        <delete file="./i2psnark-standalone.zip" />
205        <delete dir="./dist" />
206    </target>
207    <target name="cleandep" depends="clean">
208    </target>
209    <target name="distclean" depends="clean">
210    </target>
211</project>
Note: See TracBrowser for help on using the repository browser.