source: apps/jetty/build.xml @ a468b3e

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

Build: Remove commons-logging classes from commons-logging.jar (ticket #1679)

  • Property mode set to 100644
File size: 17.8 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.17.v20150415" />
5    <property name="jetty.base" value="jetty-distribution-${jetty.ver}" />
6    <property name="jetty.sha1" value="ce7bcd1bdcdac4cf130467f6d55155b9e1517e71" />
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.44" />
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      <!--
153        * Removed in 0.9.24, see ticket #1679
154        * Jetty now uses tomcat-juli (added below to commons-logging.jar), not commons-logging proper,
155        * and no known plugins use it either.
156        <jar destfile="jettylib/commons-logging.jar" filesetmanifest="mergewithoutmain" >
157            <zipfileset excludes="META-INF/LICENSE.txt META-INF/NOTICE.txt" src="../../installer/lib/launch4j/lib/commons-logging.jar" />
158        </jar>
159      -->
160        <ant target="copyTomcatLib" />
161    </target>
162
163    <!-- Tomcat util jar.
164         As of Tomcat 6.0.39, the deployer does not contain some classes that are required
165         to precompile jsps with tags (SusiDNS and i2p-bote).
166         These classes are in the main Tomcat package, in lib/tomcat-coyote.jar.
167         As the jar is 800 KB and we only need 12 KB of that, we extract the required classes
168         to a new jar, created and checked in using this target.
169         Apparently this is only required for precompilation of jsps, so this is put in
170         with the JspC compiler jasper-runtime.jar below.
171     -->
172    <target name="buildTomcatUtilJar" >
173        <!-- take only what we need from the tomcat-coyote jar -->
174        <jar destfile="${tomcat2.lib.small}/tomcat-coyote-util.jar" >
175            <zipfileset src="${tomcat2.lib}/tomcat-coyote.jar"
176             includes="org/apache/tomcat/util/descriptor/* org/apache/tomcat/util/res/*" />
177        </jar>
178    </target>
179
180    <!-- Tomcat.
181         The glassfish jars bundled in Jetty 6 are way too old.
182         For compatibility with very old I2P installations where the classpath
183         was set individually in wrapper.config, we rename and combine the jars as follows:
184         jasper.jar : jasper-runtime.jar
185         jasper-el.jar + el-api.jar : commons-el.jar
186         tomcat-juli.jar : Add to commons-logging.jar
187         empty jar : jasper-compiler.jar
188         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
189
190         Not as of Jetty 8 (using from Jetty):
191         servlet-api.jar + jsp-api.jar : javax.servlet.jar
192         If we go to Tomcat 7:
193         tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
194     -->
195    <target name="copyTomcatLib" >
196        <jar destfile="jettylib/jasper-runtime.jar" filesetmanifest="merge" >
197            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper.jar" />
198            <zipfileset src="${tomcat2.lib.small}/tomcat-coyote-util.jar" />
199        </jar>
200        <jar destfile="jettylib/commons-el.jar" duplicate="preserve" filesetmanifest="merge" >
201            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
202            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
203        </jar>
204<!--
205        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
206            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
207            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
208            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-api.jar" />
209            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-util.jar" />
210        </jar>
211-->
212        <!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
213             Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
214          -->
215        <jar destfile="jettylib/commons-logging.jar" update="true" >
216            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
217        </jar>
218        <jar destfile="jettylib/jasper-compiler.jar" >
219            <manifest>
220                <attribute name="Note" value="Intentionally empty" />
221            </manifest>
222        </jar>
223    </target>
224
225    <target name="build" depends="jar" />
226
227    <target name="builddep" />
228
229    <condition property="depend.available">
230        <typefound name="depend" />
231    </condition>
232
233    <target name="depend" if="depend.available">
234        <depend
235            cache="../../build"
236            srcdir="./java/src" 
237            destdir="./build/obj" >
238            <classpath>
239                <pathelement location="../../../core/java/build/i2p.jar" />
240                <pathelement location="./jettylib/commons-logging.jar" />
241                <pathelement location="./jettylib/org.mortbay.jetty.jar" />
242                <pathelement location="./jettylib/javax.servlet.jar" />
243                <pathelement location="./jettylib/jetty-http.jar" />
244                <pathelement location="./jettylib/jetty-io.jar" />
245                <pathelement location="./jettylib/jetty-security.jar" />
246                <pathelement location="./jettylib/jetty-util.jar" />
247                <pathelement location="./jettylib/jetty-xml.jar" />
248            </classpath>
249        </depend>
250    </target>
251
252    <target name="compile" depends="builddep, ensureJettylib, depend" >
253        <mkdir dir="./build" />
254        <mkdir dir="./build/obj" />
255        <javac 
256            srcdir="./java/src" 
257            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}" 
258            destdir="./build/obj" 
259            includeAntRuntime="false"
260            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" >
261            <compilerarg line="${javac.compilerargs}" />
262        </javac>
263    </target>
264
265    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
266        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
267            <arg value="list" />
268            <arg value="changed" />
269            <arg value="." />
270        </exec>
271        <!-- \n in an attribute value generates an invalid manifest -->
272        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
273            <arg value="-s" />
274            <arg value="[:space:]" />
275            <arg value="," />
276        </exec>
277    </target>
278
279    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
280         put our stuff in its own jar so we can work with standard Jetty 6 packages
281      -->
282    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
283        <!-- set if unset -->
284        <property name="workspace.changes.tr" value="" />
285        <copy todir="build/obj" file="resources/log4j.properties" />
286        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
287            <manifest>
288                <attribute name="Built-By" value="${build.built-by}" />
289                <attribute name="Build-Date" value="${build.timestamp}" />
290                <attribute name="Base-Revision" value="${workspace.version}" />
291                <!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
292                <attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
293                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
294            </manifest>
295        </jar>
296    </target>   
297
298    <target name="jarUpToDate">
299        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
300            <srcfiles dir= "build/obj" includes="**/*.class" />
301        </uptodate>
302        <condition property="shouldListChanges" >
303            <and>
304                <not>
305                    <isset property="jar.uptodate" />
306                </not>
307                <isset property="mtn.available" />
308            </and>
309        </condition>
310    </target>   
311
312    <target name="clean" >
313        <delete dir="./build" />
314        <delete file="${verified.filename}" />
315    </target>   
316    <target name="cleandep" depends="clean" />
317    <target name="distclean" depends="clean">
318        <delete dir="./jettylib" />
319      <!--
320        <echo message="Not actually deleting the jetty libs (since they're so large)" />
321       -->
322    </target>
323    <target name="reallyclean" depends="distclean">
324    </target>
325    <target name="totallyclean" depends="clean">
326        <delete dir="./jettylib" />
327        <delete file="${jetty.filename}" />
328    </target>
329    <target name="javadoc" >
330        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
331        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
332        <ant target="fetchJettylib" />
333        <ant target="verifyJettylib" />
334        <ant target="extractJavadoc" />
335    </target>
336    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
337        <mkdir dir="./build" />
338        <mkdir dir="./build/javadoc" />
339        <unzip src="${jetty.filename}" dest="./build/javadoc" >
340            <patternset>
341                <include name="${jetty.base}/javadoc/" />
342            </patternset>
343            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
344        </unzip>
345    </target>
346
347</project>
Note: See TracBrowser for help on using the repository browser.