source: apps/jetty/build.xml @ 8104cb4

Last change on this file since 8104cb4 was 703f28e, checked in by zzz <zzz@…>, 8 years ago
  • Build:
    • Include old commons logging classes in commons-logging.jar
    • Preserve manifests in Jetty/Tomcat? jars
  • Jetty Logger: Promote warns to erros when a Throwable is the second arg
  • Property mode set to 100644
File size: 12.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="jetty">
3
4    <property name="jetty.ver" value="6.1.26" />
5    <property name="jetty.base" value="jetty-${jetty.ver}" />
6    <property name="jetty.sha1" value="9485913f1a1945a849a90f1a34853d22350bc524" />
7    <property name="jetty.filename" value="${jetty.base}.zip" />
8    <property name="jetty.url" value="http://dist.codehaus.org/jetty/${jetty.base}/${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-sslengine-xxx.jar: SSL NIO Connector for console
93              jetty-java5-threadpool-xxx.jar: Concurrent thread pool for eepsite
94              glassfish 2.1: Not used, too old, see Tomcat below.
95              jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
96              jetty-management: Not used by I2P, but only 34KB and could be useful for eepsites, and we bundled it with Jetty 5
97              All of these are available in the Ubuntu packages libjetty-java and libjetty-extra-java
98        -->
99        <copy preservelastmodified="true" file="${jetty.base}/start.jar" tofile="jettylib/jetty-start.jar" />
100        <copy file="${jetty.base}/lib/${jetty.base}.jar" tofile="jettylib/org.mortbay.jetty.jar" />
101        <copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
102        <copy preservelastmodified="true" file="${jetty.base}/lib/ext/jetty-java5-threadpool-${jetty.ver}.jar" tofile="jettylib/jetty-java5-threadpool.jar" />
103        <copy preservelastmodified="true" file="${jetty.base}/lib/ext/jetty-rewrite-handler-${jetty.ver}.jar" tofile="jettylib/jetty-rewrite-handler.jar" />
104        <copy preservelastmodified="true" file="${jetty.base}/lib/ext/jetty-sslengine-${jetty.ver}.jar" tofile="jettylib/jetty-sslengine.jar" />
105        <copy preservelastmodified="true" file="${jetty.base}/lib/management/jetty-management-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jmx.jar" />
106        <delete file="jetty.tar" />
107      <!--
108        <delete dir="${jetty.base}" />
109      -->
110        <!-- commons-logging.jar not in Jetty 6 but we have it in launch4j so copy it over,
111             needed for old plugins and things. We add tomcat-juli below.
112          -->
113        <jar destfile="jettylib/commons-logging.jar" filesetmanifest="mergewithoutmain" >
114            <zipfileset excludes="META-INF/LICENSE.txt META-INF/NOTICE.txt" src="../../installer/lib/launch4j/lib/commons-logging.jar" />
115        </jar>
116        <ant target="copyTomcatLib" />
117    </target>
118
119    <!-- Tomcat.
120         The glassfish jars bundled in Jetty 6 are way too old.
121         For compatibility with very old I2P installations where the classpath
122         was set individually in wrapper.config, we rename and combine the jars as follows:
123         jasper.jar : jasper-runtime.jar
124         jasper-el.jar + el-api.jar : commons-el.jar
125         servlet-api.jar + jsp-api.jar : javax.servlet.jar
126         tomcat-juli.jar : Add to commons-logging.jar
127         empty jar : jasper-compiler.jar
128         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
129     -->
130    <target name="copyTomcatLib" >
131        <jar destfile="jettylib/jasper-runtime.jar" filesetmanifest="merge" >
132            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper.jar" />
133        </jar>
134        <jar destfile="jettylib/commons-el.jar" duplicate="preserve" filesetmanifest="merge" >
135            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
136            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
137        </jar>
138        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
139            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
140            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
141        </jar>
142        <!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
143             Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
144          -->
145        <jar destfile="jettylib/commons-logging.jar" update="true" >
146            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
147        </jar>
148        <jar destfile="jettylib/jasper-compiler.jar" >
149            <manifest>
150                <attribute name="Note" value="Intentionally empty" />
151            </manifest>
152        </jar>
153    </target>
154
155    <target name="build" depends="jar" />
156
157    <target name="builddep" />
158    <target name="compile" depends="builddep, ensureJettylib" >
159        <mkdir dir="./build" />
160        <mkdir dir="./build/obj" />
161        <javac 
162            srcdir="./java/src" 
163            debug="true" source="1.5" target="1.5" 
164            destdir="./build/obj" 
165            includeAntRuntime="false"
166            classpath="../../core/java/build/i2p.jar:./jettylib/commons-logging.jar:./jettylib/javax.servlet.jar:./jettylib/org.mortbay.jetty.jar:./jettylib/jetty-util.jar" >
167            <compilerarg line="${javac.compilerargs}" />
168        </javac>
169    </target>
170
171    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
172        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
173            <arg value="list" />
174            <arg value="changed" />
175            <arg value="." />
176        </exec>
177        <!-- \n in an attribute value generates an invalid manifest -->
178        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
179            <arg value="-s" />
180            <arg value="[:space:]" />
181            <arg value="," />
182        </exec>
183    </target>
184
185    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
186         put our stuff in its own jar so we can work with standard Jetty 6 packages
187      -->
188    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
189        <!-- set if unset -->
190        <property name="workspace.changes.tr" value="" />
191        <!-- old jetty 5 classes blow up the build if you forgot to do distclean -->
192        <delete dir="build/obj/org" />
193        <copy todir="build/obj" file="resources/log4j.properties" />
194        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
195            <manifest>
196                <attribute name="Built-By" value="${build.built-by}" />
197                <attribute name="Build-Date" value="${build.timestamp}" />
198                <attribute name="Base-Revision" value="${workspace.version}" />
199                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
200            </manifest>
201        </jar>
202    </target>   
203
204    <target name="jarUpToDate">
205        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
206            <srcfiles dir= "build/obj" includes="**/*.class" />
207        </uptodate>
208        <condition property="shouldListChanges" >
209            <and>
210                <not>
211                    <isset property="jar.uptodate" />
212                </not>
213                <isset property="mtn.available" />
214            </and>
215        </condition>
216    </target>   
217
218    <target name="clean" >
219        <delete dir="./build" />
220        <delete file="${verified.filename}" />
221    </target>   
222    <target name="cleandep" depends="clean" />
223    <target name="distclean" depends="clean">
224        <delete dir="./jettylib" />
225      <!--
226        <echo message="Not actually deleting the jetty libs (since they're so large)" />
227       -->
228    </target>
229    <target name="reallyclean" depends="distclean">
230    </target>
231    <target name="totallyclean" depends="clean">
232        <delete dir="./jettylib" />
233        <delete file="${jetty.filename}" />
234    </target>
235    <target name="javadoc" >
236        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
237        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
238        <ant target="fetchJettylib" />
239        <ant target="verifyJettylib" />
240        <ant target="extractJavadoc" />
241    </target>
242    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
243        <mkdir dir="./build" />
244        <mkdir dir="./build/javadoc" />
245        <unzip src="${jetty.filename}" dest="./build/javadoc" >
246            <patternset>
247                <include name="${jetty.base}/javadoc/" />
248            </patternset>
249            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
250        </unzip>
251    </target>
252
253</project>
Note: See TracBrowser for help on using the repository browser.