source: apps/jetty/build.xml @ ec6c244

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

Debian build fixes

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