source: apps/jetty/build.xml @ c66559f

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

propagate from branch 'i2p.i2p' (head d2e954c054d89a425c9791067ac7998433e95a23)

to branch 'i2p.i2p.zzz.jetty9' (head adcba23cab31b88e430ee09bf45fd1b6789a1719)

  • Property mode set to 100644
File size: 20.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-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    <!-- unused until we go to 9.3 -->
18    <property name="jetty.branch" value="stable-9" />
19    <property name="jetty.ver" value="9.2.20.v20161216" />
20    <property name="jetty.base" value="jetty-distribution-${jetty.ver}" />
21    <property name="jetty.sha1" value="1ea78a0d8a4ca500c8d99c89950544223008e471" />
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    <property name="tomcat.lib" value="apache-tomcat-deployer/lib" />
29    <property name="tomcat.ver" value="6.0.48" />
30    <property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" />
31    <property name="tomcat2.lib.small" value="apache-tomcat/lib" />
32
33    <target name="all" depends="build" />
34
35    <!--
36      - We now check in the jars we need to ${jetty.base}, so
37      - fetchJettylib, verifyJettylib, and extractJettylib are not used unless
38      - updating to a new Jetty version by changing ${jetty.ver} and ${jetty.sha1} above.
39     -->
40
41    <!-- verify everything we need is in jettylib/ -->
42    <target name="ensureJettylib" depends="ensureJettylib1, copyJettylib" />
43
44    <target name="ensureJettylib1" >
45        <condition property="jetty.zip.extracted" >
46            <or>
47                <istrue value="${with-libjetty8-java}" />
48                <available file="${jetty.base}" type="dir" />
49            </or>
50        </condition>
51        <condition property="jetty.zip.available" >
52            <or>
53                <istrue value="${jetty.zip.extracted}" />
54                <available file="${jetty.filename}" type="file" />
55            </or>
56        </condition>
57        <condition property="verified.already" >
58            <or>
59                <istrue value="${with-libjetty8-java}" />
60                <istrue value="${jetty.zip.extracted}" />
61                <and>
62                    <available file="${jetty.filename}" />
63                    <uptodate property="foo.bar.baz" srcfile="${jetty.filename}" targetfile="${verified.filename}" />
64                </and>
65            </or>
66        </condition>
67    </target>
68
69  <!--
70    <target name="ensureJettylib" depends="extractJettylib" />
71   -->
72
73    <target name="fetchJettylib" unless="jetty.zip.available" >
74        <echo message="It seems that you don't have '${jetty.filename}' deployed." />
75        <echo message="The build script can download this file for you automatically," />
76        <echo message="or alternatively you can obtain it manually from:" />
77        <echo message="${jetty.url}" />
78        <echo message="" />
79        <echo message="The libraries contained in the fetched file provide the Jetty web server" />
80        <echo message="(http://jetty.mortbay.org/). They are not absolutely necessary" />
81        <echo message="but strongly recommended, since they are used by some applications" />
82        <echo message="on top of I2P, like the router console." />
83        <echo message="" />
84        <echo message="Even if you deploy the Jetty archive manually into directory apps/jetty/," />
85        <echo message="the build script will still attempt to verify its checksums, which must be:" />
86        <echo message="SHA1 ${jetty.sha1}" />
87        <echo message="" />
88        <input message="Download Jetty archive automatically?" validargs="y,n" addproperty="jetty.download" />
89        <fail message="Aborting as requested. Please deploy the Jetty archive manually." >
90            <condition>
91                <equals arg1="${jetty.download}" arg2="n"/>
92            </condition>
93        </fail>
94        <get src="${jetty.url}" verbose="true" dest="${jetty.filename}" />
95    </target>
96
97    <target name="verifyJettylib" depends="fetchJettylib" unless="verified.already" >
98        <condition property="jetty.zip.verified" >
99                <checksum file="${jetty.filename}" algorithm="SHA" property="${jetty.sha1}" />
100        </condition>
101        <fail message="Jetty archive does not match its checksum!" >
102            <condition>
103                <not>
104                    <istrue value="${jetty.zip.verified}" />
105                </not>
106            </condition>
107        </fail>
108        <touch file="${verified.filename}" />
109    </target>
110
111    <target name="extractJettylib" depends="verifyJettylib" unless="jetty.zip.extracted" >
112      <!-- for .tgz -->
113      <!--
114        <gunzip src="${jetty.filename}" dest="jetty.tar" />
115        <untar src="jetty.tar" dest="." />
116      -->
117      <!-- for .zip -->
118        <unzip src="${jetty.filename}" dest="." />
119    </target>
120
121    <target name="mkJettylibdir" >
122        <mkdir dir="jettylib" />
123    </target>
124
125    <!-- Jetty and tomcat files -->
126    <target name="copyJettylib" depends="mkJettylibdir, copyJettylib1, copyTomcatLib" />
127
128    <!-- Jetty files only -->
129    <target name="copyJettylib1" depends="extractJettylib" unless="${with-libjetty8-java}" >
130      <!-- We copy everything to names without the version numbers so we
131           can update them later. Where there was something similar in Jetty 5/6,
132           we use the same names so they will overwrite the Jetty 5/6 jar on upgrade.
133           Otherwise we use the same name as the symlink in Ubuntu /usr/share/java.
134           Reasons for inclusion:
135              start.jar: Needed for clients.config startup of eepsites
136              jetty-util-xxx.jar: LifeCycle (base class for stuff), URIUtil (used in i2psnark)
137              jetty-deploy, -http, -io, -security, -servlet, -webapp: All split out from main server jar in Jetty 7
138              jetty-continuation-xxx.jar: Needed? Useful?
139              jetty-servlets-xxx.jar: Needed for CGI for eepsite
140              jetty-sslengine-xxx.jar: Old Jetty 6, now a dummy
141              jetty-java5-threadpool-xxx.jar: Old Jetty 6, now a dummy
142              jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
143              jetty-management: Not used by I2P, but only 34KB and could be useful for eepsites, and we bundled it with Jetty 5
144              javax.servlet.jsp-2.2.0.v201112011158.jar: Required API
145              servlet-api-3.0.jar: Required API
146              All of these are available in the Ubuntu packages libjetty-java and libjetty-extra-java
147        -->
148        <copy preservelastmodified="true" file="${jetty.base}/start.jar" tofile="jettylib/jetty-start.jar" />
149        <copy file="${jetty.base}/lib/jetty-server-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jetty.jar" />
150        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-continuation-${jetty.ver}.jar" tofile="jettylib/jetty-continuation.jar" />
151        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-deploy-${jetty.ver}.jar" tofile="jettylib/jetty-deploy.jar" />
152        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-http-${jetty.ver}.jar" tofile="jettylib/jetty-http.jar" />
153        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-io-${jetty.ver}.jar" tofile="jettylib/jetty-io.jar" />
154        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-jmx-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jmx.jar" />
155        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-rewrite-${jetty.ver}.jar" tofile="jettylib/jetty-rewrite-handler.jar" />
156        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-security-${jetty.ver}.jar" tofile="jettylib/jetty-security.jar" />
157        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlet-${jetty.ver}.jar" tofile="jettylib/jetty-servlet.jar" />
158        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlets-${jetty.ver}.jar" tofile="jettylib/jetty-servlets.jar" />
159        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
160        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-webapp-${jetty.ver}.jar" tofile="jettylib/jetty-webapp.jar" />
161        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-xml-${jetty.ver}.jar" tofile="jettylib/jetty-xml.jar" />
162        <jar destfile="jettylib/jetty-java5-threadpool.jar" >
163            <manifest>
164                <attribute name="Note" value="Intentionally empty" />
165            </manifest>
166        </jar>
167        <jar destfile="jettylib/jetty-sslengine.jar" >
168            <manifest>
169                <attribute name="Note" value="Intentionally empty" />
170            </manifest>
171        </jar>
172        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
173            <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" />
174            <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" />
175            <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.3.2.jar" />
176        </jar>
177      <!--
178        <delete file="jetty.tar" />
179        <delete dir="${jetty.base}" />
180      -->
181        <!-- commons-logging.jar not in Jetty 6 but we have it in launch4j so copy it over,
182             needed for old plugins and things. We add tomcat-juli below.
183          -->
184      <!--
185        * Removed in 0.9.24, see ticket #1679
186        * Jetty now uses tomcat-juli (added below to commons-logging.jar), not commons-logging proper,
187        * and no known plugins use it either.
188        <jar destfile="jettylib/commons-logging.jar" filesetmanifest="mergewithoutmain" >
189            <zipfileset excludes="META-INF/LICENSE.txt META-INF/NOTICE.txt" src="../../installer/lib/launch4j/lib/commons-logging.jar" />
190        </jar>
191      -->
192    </target>
193
194    <!-- Tomcat util jar.
195         As of Tomcat 6.0.39, the deployer does not contain some classes that are required
196         to precompile jsps with tags (SusiDNS and i2p-bote).
197         These classes are in the main Tomcat package, in lib/tomcat-coyote.jar.
198         As the jar is 800 KB and we only need 12 KB of that, we extract the required classes
199         to a new jar, created and checked in using this target.
200         Apparently this is only required for precompilation of jsps, so this is put in
201         with the JspC compiler jasper-runtime.jar below.
202     -->
203    <target name="buildTomcatUtilJar" unless="${with-libservlet2.5-java}" >
204        <!-- take only what we need from the tomcat-coyote jar -->
205        <jar destfile="${tomcat2.lib.small}/tomcat-coyote-util.jar" >
206            <zipfileset src="${tomcat2.lib}/tomcat-coyote.jar"
207             includes="org/apache/tomcat/util/descriptor/* org/apache/tomcat/util/res/*" />
208        </jar>
209    </target>
210
211    <!-- Tomcat.
212         The glassfish jars bundled in Jetty 6 are way too old.
213         For compatibility with very old I2P installations where the classpath
214         was set individually in wrapper.config, we rename and combine the jars as follows:
215         jasper.jar : jasper-runtime.jar
216         jasper-el.jar + el-api.jar : commons-el.jar
217         tomcat-juli.jar : Add to commons-logging.jar
218         empty jar : jasper-compiler.jar
219         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
220
221         Not as of Jetty 8 (using from Jetty):
222         servlet-api.jar + jsp-api.jar : javax.servlet.jar
223         If we go to Tomcat 7:
224         tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
225     -->
226    <target name="copyTomcatLib" depends="mkJettylibdir, copyTomcatLib1, copyTomcatLib2, copyTomcatLib3" />
227
228    <target name="copyTomcatLib1" unless="${with-libservlet2.5-java}" >
229        <condition property="with-libtomcat-java" >
230            <or>
231                <istrue value="${with-libtomcat6-java}" />
232                <istrue value="${with-libtomcat7-java}" />
233                <istrue value="${with-libtomcat8-java}" />
234            </or>
235        </condition>
236    </target>
237
238
239    <target name="copyTomcatLib2" unless="${with-libtomcat-java}" >
240        <!-- EL libs.
241             Tomcat 6 has EL 2.1.
242             Tomcat 7 / libservlet3.0 has EL 2.2.
243             According to http://stackoverflow.com/questions/7202686/differences-between-el-2-1-and-2-2
244             2.2 is backwards-compatible with 2.1.
245         -->
246        <jar destfile="jettylib/commons-el.jar" duplicate="preserve" filesetmanifest="merge" >
247            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
248            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
249        </jar>
250
251        <jar destfile="jettylib/jasper-runtime.jar" >
252            <manifest>
253                <attribute name="Note" value="Intentionally empty" />
254            </manifest>
255        </jar>
256<!--
257        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
258            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
259            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
260            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-api.jar" />
261            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-util.jar" />
262        </jar>
263-->
264        <!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
265             Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
266          -->
267        <jar destfile="jettylib/commons-logging.jar" update="true" >
268            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
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.