source: apps/jetty/build.xml @ d367149

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

Tomcat 6.0.47

  • Property mode set to 100644
File size: 19.7 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    <property name="jetty.ver" value="8.1.17.v20150415" />
17    <property name="jetty.base" value="jetty-distribution-${jetty.ver}" />
18    <property name="jetty.sha1" value="ce7bcd1bdcdac4cf130467f6d55155b9e1517e71" />
19    <property name="jetty.filename" value="${jetty.base}.zip" />
20    <property name="jetty.url" value="http://download.eclipse.org/jetty/${jetty.ver}/dist/${jetty.filename}" />
21    <property name="verified.filename" value="verified.txt" />
22    <property name="javac.compilerargs" value="" />
23    <property name="javac.version" value="1.6" />
24    <property name="tomcat.lib" value="apache-tomcat-deployer/lib" />
25    <property name="tomcat.ver" value="6.0.47" />
26    <property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" />
27    <property name="tomcat2.lib.small" value="apache-tomcat/lib" />
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-libjetty8-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-libjetty8-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    <target name="copyJettylib" depends="mkJettylibdir, copyJettylib1, copyTomcatLib" />
123
124    <!-- Jetty files only -->
125    <target name="copyJettylib1" depends="extractJettylib" unless="${with-libjetty8-java}" >
126      <!-- We copy everything to names without the version numbers so we
127           can update them later. Where there was something similar in Jetty 5/6,
128           we use the same names so they will overwrite the Jetty 5/6 jar on upgrade.
129           Otherwise we use the same name as the symlink in Ubuntu /usr/share/java.
130           Reasons for inclusion:
131              start.jar: Needed for clients.config startup of eepsites
132              jetty-util-xxx.jar: LifeCycle (base class for stuff), URIUtil (used in i2psnark)
133              jetty-deploy, -http, -io, -security, -servlet, -webapp: All split out from main server jar in Jetty 7
134              jetty-continuation-xxx.jar: Needed? Useful?
135              jetty-servlets-xxx.jar: Needed for CGI for eepsite
136              jetty-sslengine-xxx.jar: Old Jetty 6, now a dummy
137              jetty-java5-threadpool-xxx.jar: Old Jetty 6, now a dummy
138              jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
139              jetty-management: Not used by I2P, but only 34KB and could be useful for eepsites, and we bundled it with Jetty 5
140              javax.servlet.jsp-2.2.0.v201112011158.jar: Required API
141              servlet-api-3.0.jar: Required API
142              All of these are available in the Ubuntu packages libjetty-java and libjetty-extra-java
143        -->
144        <copy preservelastmodified="true" file="${jetty.base}/start.jar" tofile="jettylib/jetty-start.jar" />
145        <copy file="${jetty.base}/lib/jetty-server-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jetty.jar" />
146        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-continuation-${jetty.ver}.jar" tofile="jettylib/jetty-continuation.jar" />
147        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-deploy-${jetty.ver}.jar" tofile="jettylib/jetty-deploy.jar" />
148        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-http-${jetty.ver}.jar" tofile="jettylib/jetty-http.jar" />
149        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-io-${jetty.ver}.jar" tofile="jettylib/jetty-io.jar" />
150        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-jmx-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jmx.jar" />
151        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-rewrite-${jetty.ver}.jar" tofile="jettylib/jetty-rewrite-handler.jar" />
152        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-security-${jetty.ver}.jar" tofile="jettylib/jetty-security.jar" />
153        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlet-${jetty.ver}.jar" tofile="jettylib/jetty-servlet.jar" />
154        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlets-${jetty.ver}.jar" tofile="jettylib/jetty-servlets.jar" />
155        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
156        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-webapp-${jetty.ver}.jar" tofile="jettylib/jetty-webapp.jar" />
157        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-xml-${jetty.ver}.jar" tofile="jettylib/jetty-xml.jar" />
158        <jar destfile="jettylib/jetty-java5-threadpool.jar" >
159            <manifest>
160                <attribute name="Note" value="Intentionally empty" />
161            </manifest>
162        </jar>
163        <jar destfile="jettylib/jetty-sslengine.jar" >
164            <manifest>
165                <attribute name="Note" value="Intentionally empty" />
166            </manifest>
167        </jar>
168        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
169            <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" />
170            <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" />
171        </jar>
172      <!--
173        <delete file="jetty.tar" />
174        <delete dir="${jetty.base}" />
175      -->
176        <!-- commons-logging.jar not in Jetty 6 but we have it in launch4j so copy it over,
177             needed for old plugins and things. We add tomcat-juli below.
178          -->
179      <!--
180        * Removed in 0.9.24, see ticket #1679
181        * Jetty now uses tomcat-juli (added below to commons-logging.jar), not commons-logging proper,
182        * and no known plugins use it either.
183        <jar destfile="jettylib/commons-logging.jar" filesetmanifest="mergewithoutmain" >
184            <zipfileset excludes="META-INF/LICENSE.txt META-INF/NOTICE.txt" src="../../installer/lib/launch4j/lib/commons-logging.jar" />
185        </jar>
186      -->
187    </target>
188
189    <!-- Tomcat util jar.
190         As of Tomcat 6.0.39, the deployer does not contain some classes that are required
191         to precompile jsps with tags (SusiDNS and i2p-bote).
192         These classes are in the main Tomcat package, in lib/tomcat-coyote.jar.
193         As the jar is 800 KB and we only need 12 KB of that, we extract the required classes
194         to a new jar, created and checked in using this target.
195         Apparently this is only required for precompilation of jsps, so this is put in
196         with the JspC compiler jasper-runtime.jar below.
197     -->
198    <target name="buildTomcatUtilJar" unless="${with-libservlet2.5-java}" >
199        <!-- take only what we need from the tomcat-coyote jar -->
200        <jar destfile="${tomcat2.lib.small}/tomcat-coyote-util.jar" >
201            <zipfileset src="${tomcat2.lib}/tomcat-coyote.jar"
202             includes="org/apache/tomcat/util/descriptor/* org/apache/tomcat/util/res/*" />
203        </jar>
204    </target>
205
206    <!-- Tomcat.
207         The glassfish jars bundled in Jetty 6 are way too old.
208         For compatibility with very old I2P installations where the classpath
209         was set individually in wrapper.config, we rename and combine the jars as follows:
210         jasper.jar : jasper-runtime.jar
211         jasper-el.jar + el-api.jar : commons-el.jar
212         tomcat-juli.jar : Add to commons-logging.jar
213         empty jar : jasper-compiler.jar
214         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
215
216         Not as of Jetty 8 (using from Jetty):
217         servlet-api.jar + jsp-api.jar : javax.servlet.jar
218         If we go to Tomcat 7:
219         tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
220     -->
221    <target name="copyTomcatLib" depends="mkJettylibdir, copyTomcatLib1, copyTomcatLib2, copyTomcatLib3" />
222
223    <target name="copyTomcatLib1" unless="${with-libservlet2.5-java}" >
224        <condition property="with-libtomcat-java" >
225            <or>
226                <istrue value="${with-libtomcat6-java}" />
227                <istrue value="${with-libtomcat7-java}" />
228            </or>
229        </condition>
230    </target>
231
232
233    <target name="copyTomcatLib2" unless="${with-libtomcat-java}" >
234        <!-- EL libs.
235             Tomcat 6 has EL 2.1.
236             Tomcat 7 / libservlet3.0 has EL 2.2.
237             According to http://stackoverflow.com/questions/7202686/differences-between-el-2-1-and-2-2
238             2.2 is backwards-compatible with 2.1.
239         -->
240        <jar destfile="jettylib/commons-el.jar" duplicate="preserve" filesetmanifest="merge" >
241            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
242            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
243        </jar>
244
245        <jar destfile="jettylib/jasper-runtime.jar" filesetmanifest="merge" >
246            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper.jar" />
247            <zipfileset src="${tomcat2.lib.small}/tomcat-coyote-util.jar" />
248        </jar>
249<!--
250        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
251            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
252            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
253            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-api.jar" />
254            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-util.jar" />
255        </jar>
256-->
257        <!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
258             Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
259          -->
260        <jar destfile="jettylib/commons-logging.jar" update="true" >
261            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
262        </jar>
263    </target>
264
265    <target name="copyTomcatLib3" unless="${with-libtomcat-java}" >
266        <jar destfile="jettylib/jasper-compiler.jar" >
267            <manifest>
268                <attribute name="Note" value="Intentionally empty" />
269            </manifest>
270        </jar>
271    </target>
272
273    <target name="build" depends="jar" />
274
275    <target name="builddep" />
276
277    <condition property="depend.available">
278        <typefound name="depend" />
279    </condition>
280
281    <target name="depend" if="depend.available">
282        <depend
283            cache="../../build"
284            srcdir="./java/src" 
285            destdir="./build/obj" >
286            <classpath>
287                <pathelement location="../../../core/java/build/i2p.jar" />
288                <pathelement location="./jettylib/commons-logging.jar" />
289                <pathelement location="./jettylib/org.mortbay.jetty.jar" />
290                <pathelement location="./jettylib/javax.servlet.jar" />
291                <pathelement location="./jettylib/jetty-http.jar" />
292                <pathelement location="./jettylib/jetty-io.jar" />
293                <pathelement location="./jettylib/jetty-security.jar" />
294                <pathelement location="./jettylib/jetty-util.jar" />
295                <pathelement location="./jettylib/jetty-xml.jar" />
296            </classpath>
297        </depend>
298    </target>
299
300    <target name="compile" depends="builddep, ensureJettylib, depend" >
301        <mkdir dir="./build" />
302        <mkdir dir="./build/obj" />
303        <javac 
304            srcdir="./java/src" 
305            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
306            destdir="./build/obj" 
307            includeAntRuntime="false"
308            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" >
309            <compilerarg line="${javac.compilerargs}" />
310        </javac>
311    </target>
312
313    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
314        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
315            <arg value="list" />
316            <arg value="changed" />
317            <arg value="." />
318        </exec>
319        <!-- \n in an attribute value generates an invalid manifest -->
320        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
321            <arg value="-s" />
322            <arg value="[:space:]" />
323            <arg value="," />
324        </exec>
325    </target>
326
327    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
328         put our stuff in its own jar so we can work with standard Jetty 6 packages
329      -->
330    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
331        <!-- set if unset -->
332        <property name="workspace.changes.tr" value="" />
333        <copy todir="build/obj" file="resources/log4j.properties" />
334        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
335            <manifest>
336                <attribute name="Built-By" value="${build.built-by}" />
337                <attribute name="Build-Date" value="${build.timestamp}" />
338                <attribute name="Base-Revision" value="${workspace.version}" />
339                <!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
340                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
341                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
342            </manifest>
343        </jar>
344    </target>   
345
346    <target name="jarUpToDate">
347        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
348            <srcfiles dir= "build/obj" includes="**/*.class" />
349        </uptodate>
350        <condition property="shouldListChanges" >
351            <and>
352                <not>
353                    <isset property="jar.uptodate" />
354                </not>
355                <isset property="mtn.available" />
356            </and>
357        </condition>
358    </target>   
359
360    <target name="clean" >
361        <delete dir="./build" />
362        <delete file="${verified.filename}" />
363    </target>   
364    <target name="cleandep" depends="clean" />
365    <target name="distclean" depends="clean">
366        <delete dir="./jettylib" />
367      <!--
368        <echo message="Not actually deleting the jetty libs (since they're so large)" />
369       -->
370    </target>
371    <target name="reallyclean" depends="distclean">
372    </target>
373    <target name="totallyclean" depends="clean">
374        <delete dir="./jettylib" />
375        <delete file="${jetty.filename}" />
376    </target>
377    <target name="javadoc" >
378        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
379        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
380        <ant target="fetchJettylib" />
381        <ant target="verifyJettylib" />
382        <ant target="extractJavadoc" />
383    </target>
384    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
385        <mkdir dir="./build" />
386        <mkdir dir="./build/javadoc" />
387        <unzip src="${jetty.filename}" dest="./build/javadoc" >
388            <patternset>
389                <include name="${jetty.base}/javadoc/" />
390            </patternset>
391            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
392        </unzip>
393    </target>
394
395</project>
Note: See TracBrowser for help on using the repository browser.