source: apps/jetty/build.xml @ 925cacc

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

Jetty: Set up to add patch for RolloverFileOutputStream?
checked in file is unmodified from 9.2.21 for reference
patch in next checkin

  • Property mode set to 100644
File size: 21.9 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, buildPatches" 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      <!--
163        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
164       -->
165        <jar destfile="jettylib/jetty-util.jar"  manifest="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" filesetmanifest="mergewithoutmain" >
166            <zipfileset excludes="**/RolloverFileOutputStream*.class" src="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" />
167            <zipfileset src="build/jetty-util-patch.jar" />
168        </jar>
169        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-webapp-${jetty.ver}.jar" tofile="jettylib/jetty-webapp.jar" />
170        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-xml-${jetty.ver}.jar" tofile="jettylib/jetty-xml.jar" />
171        <jar destfile="jettylib/jetty-java5-threadpool.jar" >
172            <manifest>
173                <attribute name="Note" value="Intentionally empty" />
174            </manifest>
175        </jar>
176        <jar destfile="jettylib/jetty-sslengine.jar" >
177            <manifest>
178                <attribute name="Note" value="Intentionally empty" />
179            </manifest>
180        </jar>
181    </target>
182
183    <!-- If with-libtomcat8-java but not with-libjetty9-java, we don't do this -->
184    <target name="copyJettylib2" depends="extractJettylib" unless="${with-libtomcat8-java}" >
185        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
186            <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" />
187          <!--
188            Jetty version - see below for why we don't use this one
189            <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" />
190           -->
191            <!-- Apache version -->
192            <!-- Also includes org.apache.*, this is copied into jasper-runtime.jar below -->
193            <zipfileset includes="javax/**/*" src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.0.33.jar"/>
194            <!-- In Debian packages they are found in /usr/share/java/tomcat8-servlet-api.jar in the libtomcat8-java package -->
195            <!-- javax/servlet/jsp/resources are dups of those in apache-jsp jar -->
196            <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" />
197        </jar>
198      <!--
199        <delete file="jetty.tar" />
200        <delete dir="${jetty.base}" />
201      -->
202    </target>
203
204
205    <!-- Tomcat.
206         The glassfish jars bundled in Jetty 6 are way too old.
207         For compatibility with very old I2P installations where the classpath
208         was set individually in wrapper.config, we rename and combine the jars as follows:
209         jasper.jar : jasper-runtime.jar
210         jasper-el.jar + el-api.jar : commons-el.jar
211         tomcat-juli.jar : Add to commons-logging.jar
212         empty jar : jasper-compiler.jar
213         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
214
215         Not as of Jetty 8 (using from Jetty):
216         servlet-api.jar + jsp-api.jar : javax.servlet.jar
217         If we go to Tomcat 7:
218         tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
219     -->
220    <target name="copyTomcatLib" depends="mkJettylibdir, copyTomcatLib1, copyTomcatLib2, copyTomcatLib3" />
221
222    <target name="copyTomcatLib1" >
223        <condition property="with-libtomcat-java" >
224            <or>
225                <istrue value="${with-libtomcat6-java}" />
226                <istrue value="${with-libtomcat7-java}" />
227                <istrue value="${with-libtomcat8-java}" />
228            </or>
229        </condition>
230    </target>
231
232
233    <target name="copyTomcatLib2" unless="${with-libtomcat-java}" >
234        <!-- EL API and compiler libs.
235             Tomcat 6 has EL 2.1.
236             Tomcat 7 / libservlet3.0 has EL 2.2.
237             Jetty 9 / Tomcat 8 / libservlet3.1 has EL 3.0.
238             According to http://stackoverflow.com/questions/7202686/differences-between-el-2-1-and-2-2
239             2.2 is backwards-compatible with 2.1.
240         -->
241        <!-- the javax.el API, AND the com.sun.el parser -->
242        <!-- actually from jetty9, not tomcat8... this will fail unless we have the jetty files also -->
243        <jar destfile="jettylib/commons-el.jar" >
244          <!--
245            Jetty version
246            <zipfileset src="${jetty.base}/lib/jsp/javax.el-3.0.0.jar"/>
247           -->
248            <!-- Apache version -->
249            <zipfileset src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-el-8.0.33.jar"/>
250        </jar>
251
252        <!-- actually from jetty9, not tomcat8... this will fail unless we have the jetty files also -->
253        <jar destfile="jettylib/jasper-runtime.jar" >
254          <!--
255            Jetty version
256            <zipfileset src="${jetty.base}/lib/jsp/javax.servlet.jsp-2.3.2.jar"/>
257            To be included in jasper-runtime.jar?
258            Server complains "NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet" even with this included (but it still works).
259            The following file has the class, but /usr/share/java/jetty8-jsp.jar is empty
260            We don't use this one, because we want to be consistent with Debian builds that
261            must use Apache (aka libtomcat8).
262            <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" />
263           -->
264            <!-- Apache version -->
265            <!-- Also includes javax.servlet.jsp.*, this is copied into javax.servlet.jar above -->
266            <zipfileset includes="org/**/*" src="${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.0.33.jar"/>
267            <!-- required Jetty initializer (see RouterConsoleRunner) -->
268            <zipfileset src="${jetty.base}/lib/apache-jsp/org.eclipse.jetty.apache-jsp-${jetty.ver}.jar"/>
269        </jar>
270
271        <jar destfile="jettylib/commons-logging.jar" update="true" >
272            <manifest>
273                <attribute name="Note" value="Intentionally empty" />
274            </manifest>
275        </jar>
276    </target>
277
278    <target name="copyTomcatLib3" unless="${with-libtomcat-java}" >
279        <jar destfile="jettylib/jasper-compiler.jar" >
280            <manifest>
281                <attribute name="Note" value="Intentionally empty" />
282            </manifest>
283        </jar>
284    </target>
285
286    <target name="build" depends="jar" />
287
288    <target name="builddep" />
289
290    <condition property="depend.available">
291        <typefound name="depend" />
292    </condition>
293
294    <target name="depend" if="depend.available">
295        <depend
296            cache="../../build"
297            srcdir="./java/src" 
298            destdir="./build/obj" >
299            <classpath>
300                <pathelement location="../../../core/java/build/i2p.jar" />
301                <pathelement location="./jettylib/commons-logging.jar" />
302                <pathelement location="./jettylib/org.mortbay.jetty.jar" />
303                <pathelement location="./jettylib/javax.servlet.jar" />
304                <pathelement location="./jettylib/jetty-http.jar" />
305                <pathelement location="./jettylib/jetty-io.jar" />
306                <pathelement location="./jettylib/jetty-security.jar" />
307                <pathelement location="./jettylib/jetty-util.jar" />
308                <pathelement location="./jettylib/jetty-xml.jar" />
309            </classpath>
310        </depend>
311    </target>
312
313    <target name="compile" depends="builddep, ensureJettylib, depend" >
314        <mkdir dir="./build" />
315        <mkdir dir="./build/obj" />
316        <javac 
317            srcdir="./java/src" 
318            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
319            destdir="./build/obj" 
320            includeAntRuntime="false"
321            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" >
322            <compilerarg line="${javac.compilerargs}" />
323        </javac>
324    </target>
325
326    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
327        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
328            <arg value="list" />
329            <arg value="changed" />
330            <arg value="." />
331        </exec>
332        <!-- \n in an attribute value generates an invalid manifest -->
333        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
334            <arg value="-s" />
335            <arg value="[:space:]" />
336            <arg value="," />
337        </exec>
338    </target>
339
340    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
341         put our stuff in its own jar so we can work with standard Jetty 6 packages
342      -->
343    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
344        <!-- set if unset -->
345        <property name="workspace.changes.tr" value="" />
346        <copy todir="build/obj" file="resources/log4j.properties" />
347        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
348            <manifest>
349                <attribute name="Built-By" value="${build.built-by}" />
350                <attribute name="Build-Date" value="${build.timestamp}" />
351                <attribute name="Base-Revision" value="${workspace.version}" />
352                <!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
353                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
354                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
355                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
356                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
357            </manifest>
358        </jar>
359    </target>   
360
361    <target name="jarUpToDate">
362        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
363            <srcfiles dir= "build/obj" includes="**/*.class" />
364        </uptodate>
365        <condition property="shouldListChanges" >
366            <and>
367                <not>
368                    <isset property="jar.uptodate" />
369                </not>
370                <isset property="mtn.available" />
371            </and>
372        </condition>
373    </target>   
374
375    <target name="buildPatches" depends="jarPatches" unless="${with-libjetty9-java}" />
376
377    <target name="compilePatches" unless="${with-libjetty9-java}" >
378        <mkdir dir="./build" />
379        <mkdir dir="./build/objPatches" />
380        <javac 
381            srcdir="./patches/jetty-util/src/main/java" 
382            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
383            destdir="./build/objPatches" 
384            includeAntRuntime="false"
385            classpath="" >
386            <compilerarg line="${javac.compilerargs}" />
387        </javac>
388    </target>
389
390    <target name="jarPatches" depends="compilePatches, jarPatchesUpToDate" unless="jarPatches.uptodate" >
391        <jar destfile="./build/jetty-util-patch.jar" basedir="./build/objPatches" includes="**/*.class" >
392        </jar>
393    </target>   
394
395    <target name="jarPatchesUpToDate" >
396        <condition property="jarPatches.uptodate" >
397            <or>
398                <equals arg1="${with-libjetty9-java}" arg2="true" />
399                <uptodate property="jarPatches.uptodate" targetfile="jettylib/jetty-i2p.jar" >
400                    <srcfiles dir= "build/objPatches" includes="**/*.class" />
401                </uptodate>
402            </or>
403        </condition>
404    </target>   
405
406    <target name="clean" >
407        <delete dir="./build" />
408        <delete file="${verified.filename}" />
409    </target>   
410    <target name="cleandep" depends="clean" />
411    <target name="distclean" depends="clean">
412        <delete dir="./jettylib" />
413      <!--
414        <echo message="Not actually deleting the jetty libs (since they're so large)" />
415       -->
416    </target>
417    <target name="reallyclean" depends="distclean">
418    </target>
419    <target name="totallyclean" depends="clean">
420        <delete dir="./jettylib" />
421        <delete file="${jetty.filename}" />
422    </target>
423    <target name="javadoc" >
424        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
425        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
426        <ant target="fetchJettylib" />
427        <ant target="verifyJettylib" />
428        <ant target="extractJavadoc" />
429    </target>
430    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
431        <mkdir dir="./build" />
432        <mkdir dir="./build/javadoc" />
433        <unzip src="${jetty.filename}" dest="./build/javadoc" >
434            <patternset>
435                <include name="${jetty.base}/javadoc/" />
436            </patternset>
437            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
438        </unzip>
439    </target>
440
441</project>
Note: See TracBrowser for help on using the repository browser.