source: apps/jetty/build.xml @ cadedeb0

Last change on this file since cadedeb0 was cadedeb0, checked in by zzz <zzz@…>, 8 years ago
  • Build: Add built-by to jars; check for corrupt jars on debug page
  • Property mode set to 100644
File size: 7.6 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="Built-By" value="${build.built-by}" />
121                <attribute name="Build-Date" value="${build.timestamp}" />
122                <attribute name="Base-Revision" value="${workspace.version}" />
123                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
124            </manifest>
125        </jar>
126    </target>   
127
128    <target name="jarUpToDate">
129        <uptodate property="jar.uptodate" targetfile="jettylib/org.mortbay.jetty.jar" >
130            <srcfiles dir= "build/obj" includes="**/*.class" />
131        </uptodate>
132        <condition property="shouldListChanges" >
133            <and>
134                <not>
135                    <isset property="jar.uptodate" />
136                </not>
137                <isset property="mtn.available" />
138            </and>
139        </condition>
140    </target>   
141
142    <target name="clean" >
143        <delete dir="./build" />
144        <delete file="${verified.filename}" />
145    </target>   
146    <target name="cleandep" depends="clean" />
147    <target name="distclean" depends="clean">
148        <delete dir="./jettylib" />
149        <echo message="Not actually deleting the jetty libs (since they're so large)" />
150    </target>
151    <target name="reallyclean" depends="distclean">
152    </target>
153    <target name="totallyclean" depends="clean">
154        <delete dir="./jettylib" />
155        <delete file="${jetty.filename}" />
156    </target>
157    <target name="javadoc" >
158        <available property="jetty.zip.available" file="${jetty.filename}" type="file" />
159        <available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
160        <ant target="fetchJettylib" />
161        <ant target="verifyJettylib" />
162        <ant target="extractJavadoc" />
163    </target>
164    <target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
165        <mkdir dir="./build" />
166        <mkdir dir="./build/javadoc" />
167        <unzip src="${jetty.filename}" dest="./build/javadoc" >
168            <patternset>
169                <include name="${jetty.base}/javadoc/" />
170            </patternset>
171            <mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
172        </unzip>
173    </target>
174
175</project>
Note: See TracBrowser for help on using the repository browser.