source: apps/jetty/build.xml @ 4045785

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

bundle jmx

  • Property mode set to 100644
File size: 11.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="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        <copy file="${jetty.base}/lib/jsp-2.1/ant-1.6.5.jar" tofile="jettylib/ant.jar" />
99        <delete file="jetty.tar" />
100        <delete dir="${jetty.base}" />
101        <!-- commons-logging.jar not in Jetty 6 but we have it in launch4j so copy it over, we need it
102             for org.apache.jasper.JspC compiler
103          -->
104        <copy preservelastmodified="true" file="../../installer/lib/launch4j/lib/commons-logging.jar" todir="jettylib/" />
105        <ant target="copyTomcatLib" />
106    </target>
107
108    <!-- Tomcat.
109         The glassfish jars bundled in Jetty 6 are way too old.
110         For compatibility with very old I2P installations where the classpath
111         was set individually in wrapper.config, we rename and combine the jars as follows:
112         jasper.jar : jasper-runtime.jar
113         jasper-el.jar + el-api.jar : commons-el.jar
114         servlet-api.jar + jsp-api.jar : javax.servlet.jar
115         tomcat-juli.jar : commons-logging.jar
116         empty jar : jasper-compiler.jar
117         Also, take NOTICE and LICENSE out of each one, we bundle those separately.
118     -->
119    <target name="copyTomcatLib" >
120        <jar destfile="jettylib/jasper-runtime.jar" >
121            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper.jar" />
122        </jar>
123        <jar destfile="jettylib/commons-el.jar" duplicate="preserve" >
124            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
125            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
126        </jar>
127        <jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" >
128            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
129            <zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
130        </jar>
131        <jar destfile="jettylib/commons-logging.jar" >
132            <zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
133        </jar>
134        <jar destfile="jettylib/jasper-compiler.jar" />
135    </target>
136
137    <target name="build" depends="jar" />
138
139    <target name="builddep" />
140    <target name="compile" depends="builddep, ensureJettylib" >
141        <mkdir dir="./build" />
142        <mkdir dir="./build/obj" />
143        <javac 
144            srcdir="./java/src" 
145            debug="true" source="1.5" target="1.5" 
146            destdir="./build/obj" 
147            includeAntRuntime="false"
148            classpath="../../core/java/build/i2p.jar:./jettylib/commons-logging.jar:./jettylib/javax.servlet.jar:./jettylib/org.mortbay.jetty.jar:./jettylib/jetty-util.jar" >
149            <compilerarg line="${javac.compilerargs}" />
150        </javac>
151    </target>
152
153    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
154        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
155            <arg value="list" />
156            <arg value="changed" />
157            <arg value="." />
158        </exec>
159        <!-- \n in an attribute value generates an invalid manifest -->
160        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
161            <arg value="-s" />
162            <arg value="[:space:]" />
163            <arg value="," />
164        </exec>
165    </target>
166
167    <!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
168         put our stuff in its own jar so we can work with standard Jetty 6 packages
169      -->
170    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
171        <!-- set if unset -->
172        <property name="workspace.changes.tr" value="" />
173        <copy todir="build/obj" file="resources/log4j.properties" />
174        <jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
175            <manifest>
176                <attribute name="Build-Date" value="${build.timestamp}" />
177                <attribute name="Base-Revision" value="${workspace.version}" />
178                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
179            </manifest>
180        </jar>
181    </target>   
182
183    <target name="jarUpToDate">
184        <uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
185            <srcfiles dir= "build/obj" includes="**/*.class" />
186        </uptodate>
187        <condition property="shouldListChanges" >
188            <and>
189                <not>
190                    <isset property="jar.uptodate" />
191                </not>
192                <isset property="mtn.available" />
193            </and>
194        </condition>
195    </target>   
196
197    <target name="clean" >
198        <delete dir="./build" />
199        <delete file="${verified.filename}" />
200    </target>   
201    <target name="cleandep" depends="clean" />
202    <target name="distclean" depends="clean">
203        <delete dir="./jettylib" />
204        <echo message="Not actually deleting the jetty libs (since they're so large)" />
205    </target>
206    <target name="reallyclean" depends="distclean">
207    </target>
208    <target name="totallyclean" depends="clean">
209        <delete dir="./jettylib" />
210        <delete file="${jetty.filename}" />
211    </target>
212    <target name="javadoc" >
213        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
214        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
215        <ant target="fetchJettylib" />
216        <ant target="verifyJettylib" />
217        <ant target="extractJavadoc" />
218    </target>
219    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
220        <mkdir dir="./build" />
221        <mkdir dir="./build/javadoc" />
222        <unzip src="${jetty.filename}" dest="./build/javadoc" >
223            <patternset>
224                <include name="${jetty.base}/javadoc/" />
225            </patternset>
226            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
227        </unzip>
228    </target>
229
230</project>
Note: See TracBrowser for help on using the repository browser.