source: apps/jetty/build.xml @ 6753d23

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

Tomcat: Bundle a stripped tomcat-coyote.jar with the utils
required to precompile jsps with tags (SusiDNS and Bote).
As of 6.0.39, these utils are required but they are not bundled
in the Tomcat deployer package, the main package is required.
This checkin has only the classes required from the jar.

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