source: apps/i2psnark/java/build.xml @ 4e99c45

Last change on this file since 4e99c45 was c5f04ee, checked in by zzz <zzz@…>, 9 years ago
  • Don't do 'mtn list changed' if not in a workspace or not needed
  • Property mode set to 100644
File size: 8.5 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="../../ministreaming/java/build/obj" />
20                <pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
21                <pathelement location="../../jetty/jettylib/javax.servlet.jar" />
22            </classpath>
23        </depend>
24    </target>
25    <property name="javac.compilerargs" value="" />
26    <target name="compile" depends="depend">
27        <mkdir dir="./build" />
28        <mkdir dir="./build/obj" />
29        <javac 
30            srcdir="./src" 
31            debug="true" deprecation="on" source="1.5" target="1.5" 
32            destdir="./build/obj" 
33            includeAntRuntime="false"
34            classpath="../../../core/java/build/i2p.jar:../../jetty/jettylib/org.mortbay.jetty.jar:../../jetty/jettylib/javax.servlet.jar:../../ministreaming/java/build/mstreaming.jar" >
35            <compilerarg line="${javac.compilerargs}" />
36        </javac>
37    </target>
38
39    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
40        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
41            <arg value="list" />
42            <arg value="changed" />
43            <arg value=".." />
44        </exec>
45        <!-- \n in an attribute value generates an invalid manifest -->
46        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
47            <arg value="-s" />
48            <arg value="[:space:]" />
49            <arg value="," />
50        </exec>
51    </target>
52
53    <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
54        <!-- set if unset -->
55        <property name="workspace.changes.tr" value="" />
56        <jar destfile="./build/i2psnark.jar" basedir="./build/obj" includes="**/*.class" excludes="**/I2PSnarkServlet*.class **/messages_*.class">
57            <manifest>
58                <attribute name="Main-Class" value="org.klomp.snark.Snark" />
59                <attribute name="Class-Path" value="i2p.jar mstreaming.jar streaming.jar" />
60                <attribute name="Build-Date" value="${build.timestamp}" />
61                <attribute name="Base-Revision" value="${workspace.version}" />
62                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
63            </manifest>
64        </jar>
65    </target>   
66   
67    <target name="jarUpToDate">
68        <uptodate property="jar.uptodate" targetfile="build/i2psnark.jar" >
69            <srcfiles dir= "build/obj" includes="**/*.class" excludes="**/I2PSnarkServlet*.class **/messages_*.class" />
70        </uptodate>
71        <condition property="shouldListChanges" >
72            <and>
73                <not>
74                    <isset property="jar.uptodate" />
75                </not>
76                <not>
77                    <isset property="wjar.uptodate" />
78                </not>
79                <isset property="mtn.available" />
80            </and>
81        </condition>
82    </target>   
83
84    <!-- Ideally we would include
85      -  only include the servlet, everything else is in the jar.
86      -  However, the wrapper.config classpath in existing installs
87      -  does not include i2psnark.jar.
88      -  So we must continue to duplicate everything in the war.
89          <classes dir="./build/obj" includes="**/I2PSnarkServlet*.class" />
90     -->
91    <target name="war" depends="jar, bundle, warUpToDate, listChangedFiles" unless="war.uptodate" > 
92        <!-- set if unset -->
93        <property name="workspace.changes.tr" value="" />
94        <war destfile="../i2psnark.war" webxml="../web.xml" basedir="../" includes="_icons/*" >
95          <!-- include only the web stuff, as of 0.7.12 the router will add i2psnark.jar to the classpath for the war -->
96          <classes dir="./build/obj" includes="**/web/*.class" />
97            <manifest>
98                <attribute name="Build-Date" value="${build.timestamp}" />
99                <attribute name="Base-Revision" value="${workspace.version}" />
100                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
101            </manifest>
102        </war>
103    </target>
104   
105    <target name="warUpToDate">
106        <uptodate property="war.uptodate" targetfile="../i2psnark.war" >
107            <srcfiles dir= "." includes="build/obj/org/klomp/snark/web/*.class ../_icons/* ../web.xml" />
108        </uptodate>
109    </target>
110   
111    <target name="bundle" depends="compile">
112        <!-- Update the messages_*.po files.
113             We need to supply the bat file for windows, and then change the fail property to true -->
114        <exec executable="sh" osfamily="unix" failifexecutionfails="true" >
115            <arg value="./bundle-messages.sh" />
116        </exec>
117        <exec executable="sh" osfamily="mac" failifexecutionfails="true" >
118            <arg value="./bundle-messages.sh" />
119        </exec>
120                <!-- multi-lang is optional -->
121        <exec executable="sh" osfamily="windows" failifexecutionfails="false" >
122            <arg value="./bundle-messages.sh" />
123        </exec>
124    </target>
125
126    <target name="poupdate" depends="builddep, compile">
127        <!-- Update the messages_*.po files.  -->
128        <exec executable="sh" osfamily="unix" failifexecutionfails="true" >
129            <arg value="./bundle-messages.sh" />
130            <arg value="-p" />
131        </exec>
132        <exec executable="sh" osfamily="mac" failifexecutionfails="true" >
133            <arg value="./bundle-messages.sh" />
134            <arg value="-p" />
135        </exec>
136        <exec executable="sh" osfamily="windows" failifexecutionfails="true" >
137            <arg value="./bundle-messages.sh" />
138            <arg value="-p" />
139        </exec>
140    </target>
141
142    <target name="standalone" depends="standalone_prep">
143        <zip destfile="i2psnark-standalone.zip">
144          <zipfileset dir="./dist/" prefix="i2psnark/" />
145        </zip>
146    </target>
147    <target name="standalone_prep" depends="war">
148        <delete dir="./dist" />
149        <mkdir dir="./dist" />
150        <copy file="../launch-i2psnark" todir="./dist/" />
151        <mkdir dir="./dist/webapps" />
152        <copy file="../i2psnark.war" tofile="./dist/webapps/i2psnark.war" />
153        <mkdir dir="./dist/lib" />
154        <copy file="./build/i2psnark.jar" tofile="./dist/lib/i2psnark.jar" />
155        <copy file="../../../core/java/build/i2p.jar" tofile="./dist/lib/i2p.jar" />
156        <copy file="../../jetty/jettylib/commons-el.jar" tofile="./dist/lib/commons-el.jar" />
157        <copy file="../../jetty/jettylib/commons-logging.jar" tofile="./dist/lib/commons-logging.jar" />
158        <copy file="../../jetty/jettylib/javax.servlet.jar" tofile="./dist/lib/javax.servlet.jar" />
159        <copy file="../../jetty/jettylib/org.mortbay.jetty.jar" tofile="./dist/lib/org.mortbay.jetty.jar" />
160        <copy file="../../jetty/jettylib/jasper-compiler.jar" tofile="./dist/lib/jasper-compiler.jar" />
161        <copy file="../../jetty/jettylib/jasper-runtime.jar" tofile="./dist/lib/jasper-runtime.jar" />
162        <copy file="../../ministreaming/java/build/mstreaming.jar" tofile="./dist/lib/mstreaming.jar" />
163        <copy file="../../streaming/java/build/streaming.jar" tofile="./dist/lib/streaming.jar" />
164        <copy file="../jetty-i2psnark.xml" tofile="./dist/jetty-i2psnark.xml" />
165        <copy file="../readme-standalone.txt" tofile="./dist/readme.txt" />
166        <mkdir dir="./dist/logs" />
167
168        <zip destfile="i2psnark-standalone.zip">
169         <zipfileset dir="./dist/" prefix="i2psnark/" />
170        </zip>
171    </target>
172
173    <target name="clean">
174        <delete dir="./build" />
175        <delete file="../i2psnark.war" />
176        <delete file="./i2psnark-standalone.zip" />
177        <delete dir="./dist" />
178    </target>
179    <target name="cleandep" depends="clean">
180    </target>
181    <target name="distclean" depends="clean">
182    </target>
183</project>
Note: See TracBrowser for help on using the repository browser.