source: apps/i2psnark/java/build.xml @ 5b0680b

Last change on this file since 5b0680b was 5b0680b, checked in by zzz <zzz@…>, 2 years ago

i2psnark standalone: Add DNS rebinding protection
Add context config file to turn it off
Console: Mark request handled when rejecting in HostCheckHandler?
XSSFilter: Catch cascaded ISE

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