source: apps/jetty/build.xml @ c679091

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

target build property

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