source: apps/jetty/build.xml @ 061f96a

Last change on this file since 061f96a was 061f96a, checked in by zzz <zzz@…>, 9 years ago

Use ${ant.home}/lib/ant.jar instead of pulling ant.jar from Jetty

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