source: apps/jetty/build.xml @ a6e62afc

Last change on this file since a6e62afc was 0a1cd20, checked in by zzz <zzz@…>, 4 years ago

Debian: Updates

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