source: apps/jetty/build.xml @ db0381d

Last change on this file since db0381d was 6b4f665, checked in by zzz <zzz@…>, 4 years ago

Add more markers and protection for xml file migration
Add error message for jetty-jmx.xml migration, don't migrate
Update non-default files jetty-rewrite.xml and jetty-jmx.xml

  • Property mode set to 100644
File size: 20.2 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        <jar destfile="jettylib/commons-logging.jar" update="true" >
266            <manifest>
267                <attribute name="Note" value="Intentionally empty" />
268            </manifest>
269        </jar>
270    </target>
271
272    <target name="copyTomcatLib3" unless="${with-libtomcat-java}" >
273        <jar destfile="jettylib/jasper-compiler.jar" >
274            <manifest>
275                <attribute name="Note" value="Intentionally empty" />
276            </manifest>
277        </jar>
278    </target>
279
280    <target name="build" depends="jar" />
281
282    <target name="builddep" />
283
284    <condition property="depend.available">
285        <typefound name="depend" />
286    </condition>
287
288    <target name="depend" if="depend.available">
289        <depend
290            cache="../../build"
291            srcdir="./java/src" 
292            destdir="./build/obj" >
293            <classpath>
294                <pathelement location="../../../core/java/build/i2p.jar" />
295                <pathelement location="./jettylib/commons-logging.jar" />
296                <pathelement location="./jettylib/org.mortbay.jetty.jar" />
297                <pathelement location="./jettylib/javax.servlet.jar" />
298                <pathelement location="./jettylib/jetty-http.jar" />
299                <pathelement location="./jettylib/jetty-io.jar" />
300                <pathelement location="./jettylib/jetty-security.jar" />
301                <pathelement location="./jettylib/jetty-util.jar" />
302                <pathelement location="./jettylib/jetty-xml.jar" />
303            </classpath>
304        </depend>
305    </target>
306
307    <target name="compile" depends="builddep, ensureJettylib, depend" >
308        <mkdir dir="./build" />
309        <mkdir dir="./build/obj" />
310        <javac 
311            srcdir="./java/src" 
312            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
313            destdir="./build/obj" 
314            includeAntRuntime="false"
315            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" >
316            <compilerarg line="${javac.compilerargs}" />
317        </javac>
318    </target>
319
320    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
321        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
322            <arg value="list" />
323            <arg value="changed" />
324            <arg value="." />
325        </exec>
326        <!-- \n in an attribute value generates an invalid manifest -->
327        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
328            <arg value="-s" />
329            <arg value="[:space:]" />
330            <arg value="," />
331        </exec>
332    </target>
333
334    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
335         put our stuff in its own jar so we can work with standard Jetty 6 packages
336      -->
337    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
338        <!-- set if unset -->
339        <property name="workspace.changes.tr" value="" />
340        <copy todir="build/obj" file="resources/log4j.properties" />
341        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
342            <manifest>
343                <attribute name="Built-By" value="${build.built-by}" />
344                <attribute name="Build-Date" value="${build.timestamp}" />
345                <attribute name="Base-Revision" value="${workspace.version}" />
346                <!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
347                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
348                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
349                <attribute name="X-Compile-Source-JDK" value="${javac.version}" />
350                <attribute name="X-Compile-Target-JDK" value="${javac.version}" />
351            </manifest>
352        </jar>
353    </target>   
354
355    <target name="jarUpToDate">
356        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
357            <srcfiles dir= "build/obj" includes="**/*.class" />
358        </uptodate>
359        <condition property="shouldListChanges" >
360            <and>
361                <not>
362                    <isset property="jar.uptodate" />
363                </not>
364                <isset property="mtn.available" />
365            </and>
366        </condition>
367    </target>   
368
369    <target name="clean" >
370        <delete dir="./build" />
371        <delete file="${verified.filename}" />
372    </target>   
373    <target name="cleandep" depends="clean" />
374    <target name="distclean" depends="clean">
375        <delete dir="./jettylib" />
376      <!--
377        <echo message="Not actually deleting the jetty libs (since they're so large)" />
378       -->
379    </target>
380    <target name="reallyclean" depends="distclean">
381    </target>
382    <target name="totallyclean" depends="clean">
383        <delete dir="./jettylib" />
384        <delete file="${jetty.filename}" />
385    </target>
386    <target name="javadoc" >
387        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
388        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
389        <ant target="fetchJettylib" />
390        <ant target="verifyJettylib" />
391        <ant target="extractJavadoc" />
392    </target>
393    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
394        <mkdir dir="./build" />
395        <mkdir dir="./build/javadoc" />
396        <unzip src="${jetty.filename}" dest="./build/javadoc" >
397            <patternset>
398                <include name="${jetty.base}/javadoc/" />
399            </patternset>
400            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
401        </unzip>
402    </target>
403
404</project>
Note: See TracBrowser for help on using the repository browser.