source: apps/jetty/build.xml @ 4358d11

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