source: apps/jetty/build.xml @ f38ee48

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

Move setting of InstanceManager? to WebAppConfiguration? to avoid race
Fix up LICENSES.txt
Build.xml cleanup
Debian:

  • Add support for with-libtomcat8-java but not with-libjetty9-java for wheezy/jessie
  • Fix wheezy/precise/trusty build files to use tomcat8 but not jetty9 packages
  • Remove build dependency on ant-optional, not required
  • Remove some remaining eclipse-ecj dependencies
  • Add short README files for wheezy and jessie
  • Property mode set to 100644
File size: 20.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="jetty">
3
4    <!-- This copies jars, with some modifications and renaming,
5         from the jetty-distribution directory to the jettylib directory.
6         This is disabled if the property with-libjetty9-java=true.
7
8         This copies jars, with some modifications and renaming,
9         from the apache-tomcat-deployer and apache-tomcat directories to the jettylib directory.
10         This is disabled if the property with-libservlet2.5-java=true.
11
12         This also builds the small helper jar jetty-i2p.jar from
13         the source in the java/ directory.
14     -->
15
16    <!-- Note: Please change all references in top-level build.xml if you update to a new Jetty! -->
17    <!-- unused until we go to 9.3 -->
18    <property name="jetty.branch" value="stable-9" />
19    <property name="jetty.ver" value="9.2.21.v20170120" />
20    <property name="jetty.base" value="jetty-distribution-${jetty.ver}" />
21    <property name="jetty.sha1" value="3dcd4f66cc3f72800a2ee53fecf7b3f9d3f23eb2" />
22    <property name="jetty.filename" value="${jetty.base}.zip" />
23    <!-- change jetty.ver to jetty.branch for 9.3 -->
24    <property name="jetty.url" value="http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/${jetty.ver}/${jetty.filename}" />
25    <property name="verified.filename" value="verified.txt" />
26    <property name="javac.compilerargs" value="" />
27    <property name="javac.version" value="1.7" />
28
29    <target name="all" depends="build" />
30
31    <!--
32      - We now check in the jars we need to ${jetty.base}, so
33      - fetchJettylib, verifyJettylib, and extractJettylib are not used unless
34      - updating to a new Jetty version by changing ${jetty.ver} and ${jetty.sha1} above.
35     -->
36
37    <!-- verify everything we need is in jettylib/ -->
38    <target name="ensureJettylib" depends="ensureJettylib1, copyJettylib" />
39
40    <target name="ensureJettylib1" >
41        <condition property="jetty.zip.extracted" >
42            <or>
43                <istrue value="${with-libjetty9-java}" />
44                <available file="${jetty.base}" type="dir" />
45            </or>
46        </condition>
47        <condition property="jetty.zip.available" >
48            <or>
49                <istrue value="${jetty.zip.extracted}" />
50                <available file="${jetty.filename}" type="file" />
51            </or>
52        </condition>
53        <condition property="verified.already" >
54            <or>
55                <istrue value="${with-libjetty9-java}" />
56                <istrue value="${jetty.zip.extracted}" />
57                <and>
58                    <available file="${jetty.filename}" />
59                    <uptodate property="foo.bar.baz" srcfile="${jetty.filename}" targetfile="${verified.filename}" />
60                </and>
61            </or>
62        </condition>
63    </target>
64
65  <!--
66    <target name="ensureJettylib" depends="extractJettylib" />
67   -->
68
69    <target name="fetchJettylib" unless="jetty.zip.available" >
70        <echo message="It seems that you don't have '${jetty.filename}' deployed." />
71        <echo message="The build script can download this file for you automatically," />
72        <echo message="or alternatively you can obtain it manually from:" />
73        <echo message="${jetty.url}" />
74        <echo message="" />
75        <echo message="The libraries contained in the fetched file provide the Jetty web server" />
76        <echo message="(http://jetty.mortbay.org/). They are not absolutely necessary" />
77        <echo message="but strongly recommended, since they are used by some applications" />
78        <echo message="on top of I2P, like the router console." />
79        <echo message="" />
80        <echo message="Even if you deploy the Jetty archive manually into directory apps/jetty/," />
81        <echo message="the build script will still attempt to verify its checksums, which must be:" />
82        <echo message="SHA1 ${jetty.sha1}" />
83        <echo message="" />
84        <input message="Download Jetty archive automatically?" validargs="y,n" addproperty="jetty.download" />
85        <fail message="Aborting as requested. Please deploy the Jetty archive manually." >
86            <condition>
87                <equals arg1="${jetty.download}" arg2="n"/>
88            </condition>
89        </fail>
90        <get src="${jetty.url}" verbose="true" dest="${jetty.filename}" />
91    </target>
92
93    <target name="verifyJettylib" depends="fetchJettylib" unless="verified.already" >
94        <condition property="jetty.zip.verified" >
95                <checksum file="${jetty.filename}" algorithm="SHA" property="${jetty.sha1}" />
96        </condition>
97        <fail message="Jetty archive does not match its checksum!" >
98            <condition>
99                <not>
100                    <istrue value="${jetty.zip.verified}" />
101                </not>
102            </condition>
103        </fail>
104        <touch file="${verified.filename}" />
105    </target>
106
107    <target name="extractJettylib" depends="verifyJettylib" unless="jetty.zip.extracted" >
108      <!-- for .tgz -->
109      <!--
110        <gunzip src="${jetty.filename}" dest="jetty.tar" />
111        <untar src="jetty.tar" dest="." />
112      -->
113      <!-- for .zip -->
114        <unzip src="${jetty.filename}" dest="." />
115    </target>
116
117    <target name="mkJettylibdir" >
118        <mkdir dir="jettylib" />
119    </target>
120
121    <!-- Jetty and tomcat files -->
122    <!--
123         We support the following configurations:
124           no system jars: Precise, Trusty
125           with-libtomcat8-java: Jessie (without backports), Wheezy
126           with-libtomcat8-java AND with-libjetty9-java: Xenial, Jessie (with backports), Stretch
127           with-libjetty9-java (only): not supported
128     -->
129    <target name="copyJettylib" depends="mkJettylibdir, copyJettylib1, copyTomcatLib1, copyJettylib2, copyTomcatLib" />
130
131    <!-- Jetty files only -->
132    <target name="copyJettylib1" depends="extractJettylib" unless="${with-libjetty9-java}" >
133      <!-- We copy everything to names without the version numbers so we
134           can update them later. Where there was something similar in Jetty 5/6,
135           we use the same names so they will overwrite the Jetty 5/6 jar on upgrade.
136           Otherwise we use the same name as the symlink in Ubuntu /usr/share/java.
137           Reasons for inclusion:
138              start.jar: Needed for clients.config startup of eepsites
139              jetty-util-xxx.jar: LifeCycle (base class for stuff), URIUtil (used in i2psnark)
140              jetty-deploy, -http, -io, -security, -servlet, -webapp: All split out from main server jar in Jetty 7
141              jetty-continuation-xxx.jar: Needed? Useful?
142              jetty-servlets-xxx.jar: Needed for CGI for eepsite
143              jetty-sslengine-xxx.jar: Old Jetty 6, now a dummy
144              jetty-java5-threadpool-xxx.jar: Old Jetty 6, now a dummy
145              jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
146              jetty-management: Not used by I2P, but only 34KB and could be useful for eepsites, and we bundled it with Jetty 5
147              javax.servlet.jsp-2.2.0.v201112011158.jar: Required API
148              servlet-api-3.0.jar: Required API
149              All of these are available in the Ubuntu packages libjetty-java and libjetty-extra-java
150        -->
151        <copy preservelastmodified="true" file="${jetty.base}/start.jar" tofile="jettylib/jetty-start.jar" />
152        <copy file="${jetty.base}/lib/jetty-server-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jetty.jar" />
153        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-continuation-${jetty.ver}.jar" tofile="jettylib/jetty-continuation.jar" />
154        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-deploy-${jetty.ver}.jar" tofile="jettylib/jetty-deploy.jar" />
155        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-http-${jetty.ver}.jar" tofile="jettylib/jetty-http.jar" />
156        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-io-${jetty.ver}.jar" tofile="jettylib/jetty-io.jar" />
157        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-jmx-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jmx.jar" />
158        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-rewrite-${jetty.ver}.jar" tofile="jettylib/jetty-rewrite-handler.jar" />
159        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-security-${jetty.ver}.jar" tofile="jettylib/jetty-security.jar" />
160        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlet-${jetty.ver}.jar" tofile="jettylib/jetty-servlet.jar" />
161        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlets-${jetty.ver}.jar" tofile="jettylib/jetty-servlets.jar" />
162        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
163        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-webapp-${jetty.ver}.jar" tofile="jettylib/jetty-webapp.jar" />
164        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-xml-${jetty.ver}.jar" tofile="jettylib/jetty-xml.jar" />
165        <jar destfile="jettylib/jetty-java5-threadpool.jar" >
166            <manifest>
167                <attribute name="Note" value="Intentionally empty" />
168            </manifest>
169        </jar>
170        <jar destfile="jettylib/jetty-sslengine.jar" >
171            <manifest>
172                <attribute name="Note" value="Intentionally empty" />
173            </manifest>
174        </jar>
175    </target>
176
177    <!-- If with-libtomcat8-java but not with-libjetty9-java, we don't do this -->
178    <target name="copyJettylib2" depends="extractJettylib" unless="${with-libtomcat8-java}" >
179        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
180            <zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties" src="${jetty.base}/lib/servlet-api-3.1.jar" />
181          <!--
182            Jetty version - see below for why we don't use this one
183            <zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties" src="${jetty.base}/lib/jsp/javax.servlet.jsp-api-2.3.1.jar" />
184           -->
185            <!-- Apache version -->
186            <!-- Also includes org.apache.*, this is copied into jasper-runtime.jar below -->
187            <zipfileset includes="javax/**/*" src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.0.33.jar"/>
188            <!-- In Debian packages they are found in /usr/share/java/tomcat8-servlet-api.jar in the libtomcat8-java package -->
189            <!-- javax/servlet/jsp/resources are dups of those in apache-jsp jar -->
190            <zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties javax/servlet/jsp/resources/*" src="${jetty.base}/lib/jetty-schemas-3.1.jar" />
191        </jar>
192      <!--
193        <delete file="jetty.tar" />
194        <delete dir="${jetty.base}" />
195      -->
196    </target>
197
198
199    <!-- Tomcat.
200         The glassfish jars bundled in Jetty 6 are way too old.
201         For compatibility with very old I2P installations where the classpath
202         was set individually in wrapper.config, we rename and combine the jars as follows:
203         jasper.jar : jasper-runtime.jar
204         jasper-el.jar + el-api.jar : commons-el.jar
205         tomcat-juli.jar : Add to commons-logging.jar
206         empty jar : jasper-compiler.jar
207         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
208
209         Not as of Jetty 8 (using from Jetty):
210         servlet-api.jar + jsp-api.jar : javax.servlet.jar
211         If we go to Tomcat 7:
212         tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
213     -->
214    <target name="copyTomcatLib" depends="mkJettylibdir, copyTomcatLib1, copyTomcatLib2, copyTomcatLib3" />
215
216    <target name="copyTomcatLib1" >
217        <condition property="with-libtomcat-java" >
218            <or>
219                <istrue value="${with-libtomcat6-java}" />
220                <istrue value="${with-libtomcat7-java}" />
221                <istrue value="${with-libtomcat8-java}" />
222            </or>
223        </condition>
224    </target>
225
226
227    <target name="copyTomcatLib2" unless="${with-libtomcat-java}" >
228        <!-- EL API and compiler libs.
229             Tomcat 6 has EL 2.1.
230             Tomcat 7 / libservlet3.0 has EL 2.2.
231             Jetty 9 / Tomcat 8 / libservlet3.1 has EL 3.0.
232             According to http://stackoverflow.com/questions/7202686/differences-between-el-2-1-and-2-2
233             2.2 is backwards-compatible with 2.1.
234         -->
235        <!-- the javax.el API, AND the com.sun.el parser -->
236        <!-- actually from jetty9, not tomcat8... this will fail unless we have the jetty files also -->
237        <jar destfile="jettylib/commons-el.jar" >
238          <!--
239            Jetty version
240            <zipfileset src="${jetty.base}/lib/jsp/javax.el-3.0.0.jar"/>
241           -->
242            <!-- Apache version -->
243            <zipfileset src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-el-8.0.33.jar"/>
244        </jar>
245
246        <!-- actually from jetty9, not tomcat8... this will fail unless we have the jetty files also -->
247        <jar destfile="jettylib/jasper-runtime.jar" >
248          <!--
249            Jetty version
250            <zipfileset src="${jetty.base}/lib/jsp/javax.servlet.jsp-2.3.2.jar"/>
251            To be included in jasper-runtime.jar?
252            Server complains "NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet" even with this included (but it still works).
253            The following file has the class, but /usr/share/java/jetty8-jsp.jar is empty
254            We don't use this one, because we want to be consistent with Debian builds that
255            must use Apache (aka libtomcat8).
256            <zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties" src="${jetty.base}/lib/jsp/jetty-jsp-${jetty.ver}.jar" />
257           -->
258            <!-- Apache version -->
259            <!-- Also includes javax.servlet.jsp.*, this is copied into javax.servlet.jar above -->
260            <zipfileset includes="org/**/*" src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.0.33.jar"/>
261            <!-- required Jetty initializer (see RouterConsoleRunner) -->
262            <zipfileset src="${jetty.base}/lib/apache-jsp/org.eclipse.jetty.apache-jsp-${jetty.ver}.jar"/>
263        </jar>
264
265        <!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
266             Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
267          -->
268        <jar destfile="jettylib/commons-logging.jar" update="true" >
269            <manifest>
270                <attribute name="Note" value="Intentionally empty" />
271            </manifest>
272        </jar>
273    </target>
274
275    <target name="copyTomcatLib3" unless="${with-libtomcat-java}" >
276        <jar destfile="jettylib/jasper-compiler.jar" >
277            <manifest>
278                <attribute name="Note" value="Intentionally empty" />
279            </manifest>
280        </jar>
281    </target>
282
283    <target name="build" depends="jar" />
284
285    <target name="builddep" />
286
287    <condition property="depend.available">
288        <typefound name="depend" />
289    </condition>
290
291    <target name="depend" if="depend.available">
292        <depend
293            cache="../../build"
294            srcdir="./java/src" 
295            destdir="./build/obj" >
296            <classpath>
297                <pathelement location="../../../core/java/build/i2p.jar" />
298                <pathelement location="./jettylib/commons-logging.jar" />
299                <pathelement location="./jettylib/org.mortbay.jetty.jar" />
300                <pathelement location="./jettylib/javax.servlet.jar" />
301                <pathelement location="./jettylib/jetty-http.jar" />
302                <pathelement location="./jettylib/jetty-io.jar" />
303                <pathelement location="./jettylib/jetty-security.jar" />
304                <pathelement location="./jettylib/jetty-util.jar" />
305                <pathelement location="./jettylib/jetty-xml.jar" />
306            </classpath>
307        </depend>
308    </target>
309
310    <target name="compile" depends="builddep, ensureJettylib, depend" >
311        <mkdir dir="./build" />
312        <mkdir dir="./build/obj" />
313        <javac 
314            srcdir="./java/src" 
315            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
316            destdir="./build/obj" 
317            includeAntRuntime="false"
318            classpath="../../core/java/build/i2p.jar:./jettylib/commons-logging.jar:./jettylib/javax.servlet.jar:./jettylib/org.mortbay.jetty.jar:./jettylib/jetty-http.jar:./jettylib/jetty-io.jar:./jettylib/jetty-security.jar:./jettylib/jetty-util.jar:./jettylib/jetty-xml.jar" >
319            <compilerarg line="${javac.compilerargs}" />
320        </javac>
321    </target>
322
323    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
324        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
325            <arg value="list" />
326            <arg value="changed" />
327            <arg value="." />
328        </exec>
329        <!-- \n in an attribute value generates an invalid manifest -->
330        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
331            <arg value="-s" />
332            <arg value="[:space:]" />
333            <arg value="," />
334        </exec>
335    </target>
336
337    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
338         put our stuff in its own jar so we can work with standard Jetty 6 packages
339      -->
340    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
341        <!-- set if unset -->
342        <property name="workspace.changes.tr" value="" />
343        <copy todir="build/obj" file="resources/log4j.properties" />
344        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
345            <manifest>
346                <attribute name="Built-By" value="${build.built-by}" />
347                <attribute name="Build-Date" value="${build.timestamp}" />
348                <attribute name="Base-Revision" value="${workspace.version}" />
349                <!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
350                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
351                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
352                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
353                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
354            </manifest>
355        </jar>
356    </target>   
357
358    <target name="jarUpToDate">
359        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
360            <srcfiles dir= "build/obj" includes="**/*.class" />
361        </uptodate>
362        <condition property="shouldListChanges" >
363            <and>
364                <not>
365                    <isset property="jar.uptodate" />
366                </not>
367                <isset property="mtn.available" />
368            </and>
369        </condition>
370    </target>   
371
372    <target name="clean" >
373        <delete dir="./build" />
374        <delete file="${verified.filename}" />
375    </target>   
376    <target name="cleandep" depends="clean" />
377    <target name="distclean" depends="clean">
378        <delete dir="./jettylib" />
379      <!--
380        <echo message="Not actually deleting the jetty libs (since they're so large)" />
381       -->
382    </target>
383    <target name="reallyclean" depends="distclean">
384    </target>
385    <target name="totallyclean" depends="clean">
386        <delete dir="./jettylib" />
387        <delete file="${jetty.filename}" />
388    </target>
389    <target name="javadoc" >
390        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
391        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
392        <ant target="fetchJettylib" />
393        <ant target="verifyJettylib" />
394        <ant target="extractJavadoc" />
395    </target>
396    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
397        <mkdir dir="./build" />
398        <mkdir dir="./build/javadoc" />
399        <unzip src="${jetty.filename}" dest="./build/javadoc" >
400            <patternset>
401                <include name="${jetty.base}/javadoc/" />
402            </patternset>
403            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
404        </unzip>
405    </target>
406
407</project>
Note: See TracBrowser for help on using the repository browser.