source: apps/jetty/build.xml @ f57f49c3

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