source: apps/jetty/build.xml @ b0c3c11

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

Start work on Jetty 9
targetting 9.2.x for now
Requires Java 7

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