source: apps/jetty/build.xml @ c5f04ee

Last change on this file since c5f04ee was c5f04ee, checked in by zzz <zzz@…>, 9 years ago
  • Don't do 'mtn list changed' if not in a workspace or not needed
  • Property mode set to 100644
File size: 7.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="jetty">
3
4    <property name="jetty.base" value="jetty-5.1.15" />
5    <property name="jetty.sha1" value="3a7a3de50f86f0cdb23c33aec632ea7f44132c5e" />
6    <property name="jetty.filename" value="${jetty.base}.tgz" />
7    <property name="jetty.url" value="http://dist.codehaus.org/jetty/jetty-5.1.x/${jetty.filename}" />
8    <property name="verified.filename" value="verified.txt" />
9    <property name="javac.compilerargs" value="" />
10
11    <target name="all" depends="build" />
12
13    <target name="ensureJettylib" >
14        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
15        <available property="jetty.zip.extracted" file="jettylib" type="dir" />
16        <ant target="fetchJettylib" />
17        <ant target="verifyJettylib" />
18        <ant target="extractJettylib" />
19    </target>
20
21    <target name="fetchJettylib" unless="jetty.zip.available" >
22        <echo message="It seems that you don't have '${jetty.filename}' deployed." />
23        <echo message="The build script can download this file for you automatically," />
24        <echo message="or alternatively you can obtain it manually from:" />
25        <echo message="${jetty.url}" />
26        <echo message="" />
27        <echo message="The libraries contained in the fetched file provide the Jetty web server" />
28        <echo message="(http://jetty.mortbay.org/). They are not absolutely necessary" />
29        <echo message="but strongly recommended, since they are used by some applications" />
30        <echo message="on top of I2P, like the router console." />
31        <echo message="" />
32        <echo message="Even if you deploy the Jetty archive manually into directory apps/jetty/," />
33        <echo message="the build script will still attempt to verify its checksums, which must be:" />
34        <echo message="SHA1 ${jetty.sha1}" />
35        <echo message="" />
36        <input message="Download Jetty archive automatically?" validargs="y,n" addproperty="jetty.download" />
37        <fail message="Aborting as requested. Please deploy the Jetty archive manually." >
38            <condition>
39                <equals arg1="${jetty.download}" arg2="n"/>
40            </condition>
41        </fail>
42        <get src="${jetty.url}" verbose="true" dest="${jetty.filename}" />
43    </target>
44
45    <condition property="verified.already" >
46        <and>
47            <available file="${jetty.filename}" />
48            <uptodate property="foo.bar.baz" srcfile="${jetty.filename}" targetfile="${verified.filename}" />
49        </and>
50    </condition>
51
52    <target name="verifyJettylib" unless="verified.already" >
53        <condition property="jetty.zip.verified" >
54                <checksum file="${jetty.filename}" algorithm="SHA" property="${jetty.sha1}" />
55        </condition>
56        <fail message="Jetty archive does not match its checksum!" >
57            <condition>
58                <not>
59                    <istrue value="${jetty.zip.verified}" />
60                </not>
61            </condition>
62        </fail>
63        <touch file="${verified.filename}" />
64    </target>
65
66    <target name="extractJettylib" unless="jetty.zip.extracted" >
67        <gunzip src="${jetty.filename}" dest="jetty.tar" />
68        <untar src="jetty.tar" dest="." />
69        <mkdir dir="jettylib" />
70        <copy todir="jettylib" preservelastmodified="true" >
71            <fileset dir="${jetty.base}/lib">
72                <include name="*.jar" />
73            </fileset>
74            <fileset dir="${jetty.base}/ext">
75                <include name="ant.jar" />
76                <include name="commons-el.jar" />
77                <include name="commons-logging.jar" />
78                <include name="jasper-compiler.jar" />
79                <include name="jasper-runtime.jar" />
80            </fileset>
81        </copy>
82        <delete file="jetty.tar" />
83        <delete dir="${jetty.base}" />
84    </target>
85
86    <target name="build" depends="jar" />
87    <target name="builddep" />
88    <target name="compile" depends="builddep, ensureJettylib" >
89        <mkdir dir="./build" />
90        <mkdir dir="./build/obj" />
91        <javac 
92            srcdir="./java/src" 
93            debug="true" source="1.5" target="1.5" 
94            destdir="./build/obj" 
95            includeAntRuntime="false"
96            classpath="./jettylib/commons-logging.jar:./jettylib/javax.servlet.jar:./jettylib/org.mortbay.jetty.jar" >
97            <compilerarg line="${javac.compilerargs}" />
98        </javac>
99    </target>
100
101    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
102        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
103            <arg value="list" />
104            <arg value="changed" />
105            <arg value="." />
106        </exec>
107        <!-- \n in an attribute value generates an invalid manifest -->
108        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
109            <arg value="-s" />
110            <arg value="[:space:]" />
111            <arg value="," />
112        </exec>
113    </target>
114
115    <target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
116        <!-- set if unset -->
117        <property name="workspace.changes.tr" value="" />
118        <jar destfile="./jettylib/org.mortbay.jetty.jar" basedir="./build/obj" includes="**/*.class" update="true" >
119            <manifest>
120                <attribute name="Build-Date" value="${build.timestamp}" />
121                <attribute name="Base-Revision" value="${workspace.version}" />
122                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
123            </manifest>
124        </jar>
125    </target>   
126
127    <target name="jarUpToDate">
128        <uptodate property="jar.uptodate" targetfile="jettylib/org.mortbay.jetty.jar" >
129            <srcfiles dir= "build/obj" includes="**/*.class" />
130        </uptodate>
131        <condition property="shouldListChanges" >
132            <and>
133                <not>
134                    <isset property="jar.uptodate" />
135                </not>
136                <isset property="mtn.available" />
137            </and>
138        </condition>
139    </target>   
140
141    <target name="clean" >
142        <delete dir="./build" />
143        <delete file="${verified.filename}" />
144    </target>   
145    <target name="cleandep" depends="clean" />
146    <target name="distclean" depends="clean">
147        <delete dir="./jettylib" />
148        <echo message="Not actually deleting the jetty libs (since they're so large)" />
149    </target>
150    <target name="reallyclean" depends="distclean">
151    </target>
152    <target name="totallyclean" depends="clean">
153        <delete dir="./jettylib" />
154        <delete file="${jetty.filename}" />
155    </target>
156    <target name="javadoc" >
157        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
158        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
159        <ant target="fetchJettylib" />
160        <ant target="verifyJettylib" />
161        <ant target="extractJavadoc" />
162    </target>
163    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
164        <mkdir dir="./build" />
165        <mkdir dir="./build/javadoc" />
166        <unzip src="${jetty.filename}" dest="./build/javadoc" >
167            <patternset>
168                <include name="${jetty.base}/javadoc/" />
169            </patternset>
170            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
171        </unzip>
172    </target>
173
174</project>
Note: See TracBrowser for help on using the repository browser.