source: apps/jetty/build.xml @ 7bd83f8

Last change on this file since 7bd83f8 was 44db814, checked in by zzz <zzz@…>, 8 years ago

remove old jetty 5 classes in case you forgot to distclean after updating

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