Files
i2p.i2p/apps/jetty/build.xml
2014-09-18 13:56:48 +00:00

345 lines
18 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="jetty">
<property name="jetty.ver" value="8.1.16.v20140903" />
<property name="jetty.base" value="jetty-distribution-${jetty.ver}" />
<property name="jetty.sha1" value="5440b33a722d82b746b9ce50168bfce3c22af349" />
<property name="jetty.filename" value="${jetty.base}.zip" />
<property name="jetty.url" value="http://download.eclipse.org/jetty/${jetty.ver}/dist/${jetty.filename}" />
<property name="verified.filename" value="verified.txt" />
<property name="javac.compilerargs" value="" />
<property name="javac.version" value="1.6" />
<property name="tomcat.lib" value="apache-tomcat-deployer/lib" />
<property name="tomcat.ver" value="6.0.41" />
<property name="tomcat2.lib" value="apache-tomcat-${tomcat.ver}/lib" />
<property name="tomcat2.lib.small" value="apache-tomcat/lib" />
<target name="all" depends="build" />
<!--
- We now check in the jars we need to ${jetty.base}, so
- fetchJettylib, verifyJettylib, and extractJettylib are not used unless
- updating to a new Jetty version by changing ${jetty.ver} and ${jetty.sha1} above.
-->
<target name="ensureJettylib" >
<available property="jetty.zip.extracted" file="${jetty.base}" type="dir" />
<condition property="jetty.zip.available" >
<or>
<istrue value="${jetty.zip.extracted}" />
<available file="${jetty.filename}" type="file" />
</or>
</condition>
<ant target="copyJettylib" />
</target>
<!--
<target name="ensureJettylib" depends="extractJettylib" />
-->
<target name="fetchJettylib" unless="jetty.zip.available" >
<echo message="It seems that you don't have '${jetty.filename}' deployed." />
<echo message="The build script can download this file for you automatically," />
<echo message="or alternatively you can obtain it manually from:" />
<echo message="${jetty.url}" />
<echo message="" />
<echo message="The libraries contained in the fetched file provide the Jetty web server" />
<echo message="(http://jetty.mortbay.org/). They are not absolutely necessary" />
<echo message="but strongly recommended, since they are used by some applications" />
<echo message="on top of I2P, like the router console." />
<echo message="" />
<echo message="Even if you deploy the Jetty archive manually into directory apps/jetty/," />
<echo message="the build script will still attempt to verify its checksums, which must be:" />
<echo message="SHA1 ${jetty.sha1}" />
<echo message="" />
<input message="Download Jetty archive automatically?" validargs="y,n" addproperty="jetty.download" />
<fail message="Aborting as requested. Please deploy the Jetty archive manually." >
<condition>
<equals arg1="${jetty.download}" arg2="n"/>
</condition>
</fail>
<get src="${jetty.url}" verbose="true" dest="${jetty.filename}" />
</target>
<condition property="verified.already" >
<or>
<istrue value="${jetty.zip.extracted}" />
<and>
<available file="${jetty.filename}" />
<uptodate property="foo.bar.baz" srcfile="${jetty.filename}" targetfile="${verified.filename}" />
</and>
</or>
</condition>
<target name="verifyJettylib" depends="fetchJettylib" unless="verified.already" >
<condition property="jetty.zip.verified" >
<checksum file="${jetty.filename}" algorithm="SHA" property="${jetty.sha1}" />
</condition>
<fail message="Jetty archive does not match its checksum!" >
<condition>
<not>
<istrue value="${jetty.zip.verified}" />
</not>
</condition>
</fail>
<touch file="${verified.filename}" />
</target>
<target name="extractJettylib" depends="verifyJettylib" unless="jetty.zip.extracted" >
<!-- for .tgz -->
<!--
<gunzip src="${jetty.filename}" dest="jetty.tar" />
<untar src="jetty.tar" dest="." />
-->
<!-- for .zip -->
<unzip src="${jetty.filename}" dest="." />
</target>
<target name="copyJettylib" depends="extractJettylib" >
<mkdir dir="jettylib" />
<!-- We copy everything to names without the version numbers so we
can update them later. Where there was something similar in Jetty 5/6,
we use the same names so they will overwrite the Jetty 5/6 jar on upgrade.
Otherwise we use the same name as the symlink in Ubuntu /usr/share/java.
Reasons for inclusion:
start.jar: Needed for clients.config startup of eepsites
jetty-util-xxx.jar: LifeCycle (base class for stuff), URIUtil (used in i2psnark)
jetty-deploy, -http, -io, -security, -servlet, -webapp: All split out from main server jar in Jetty 7
jetty-continuation-xxx.jar: Needed? Useful?
jetty-servlets-xxx.jar: Needed for CGI for eepsite
jetty-sslengine-xxx.jar: Old Jetty 6, now a dummy
jetty-java5-threadpool-xxx.jar: Old Jetty 6, now a dummy
jetty-rewrite-handler: Not used by I2P, but only 20KB and could be useful for eepsites
jetty-management: Not used by I2P, but only 34KB and could be useful for eepsites, and we bundled it with Jetty 5
javax.servlet.jsp-2.2.0.v201112011158.jar: Required API
servlet-api-3.0.jar: Required API
All of these are available in the Ubuntu packages libjetty-java and libjetty-extra-java
-->
<copy preservelastmodified="true" file="${jetty.base}/start.jar" tofile="jettylib/jetty-start.jar" />
<copy file="${jetty.base}/lib/jetty-server-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jetty.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-continuation-${jetty.ver}.jar" tofile="jettylib/jetty-continuation.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-deploy-${jetty.ver}.jar" tofile="jettylib/jetty-deploy.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-http-${jetty.ver}.jar" tofile="jettylib/jetty-http.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-io-${jetty.ver}.jar" tofile="jettylib/jetty-io.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-jmx-${jetty.ver}.jar" tofile="jettylib/org.mortbay.jmx.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-rewrite-${jetty.ver}.jar" tofile="jettylib/jetty-rewrite-handler.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-security-${jetty.ver}.jar" tofile="jettylib/jetty-security.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlet-${jetty.ver}.jar" tofile="jettylib/jetty-servlet.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-servlets-${jetty.ver}.jar" tofile="jettylib/jetty-servlets.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-util-${jetty.ver}.jar" tofile="jettylib/jetty-util.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-webapp-${jetty.ver}.jar" tofile="jettylib/jetty-webapp.jar" />
<copy preservelastmodified="true" file="${jetty.base}/lib/jetty-xml-${jetty.ver}.jar" tofile="jettylib/jetty-xml.jar" />
<jar destfile="jettylib/jetty-java5-threadpool.jar" >
<manifest>
<attribute name="Note" value="Intentionally empty" />
</manifest>
</jar>
<jar destfile="jettylib/jetty-sslengine.jar" >
<manifest>
<attribute name="Note" value="Intentionally empty" />
</manifest>
</jar>
<jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
<zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties" src="${jetty.base}/lib/servlet-api-3.0.jar" />
<zipfileset excludes="about.html about_files about_files/* META-INF/ECLIPSEF.* META-INF/eclipse.inf plugin.properties" src="${jetty.base}/lib/jsp/javax.servlet.jsp-2.2.0.v201112011158.jar" />
</jar>
<!--
<delete file="jetty.tar" />
<delete dir="${jetty.base}" />
-->
<!-- commons-logging.jar not in Jetty 6 but we have it in launch4j so copy it over,
needed for old plugins and things. We add tomcat-juli below.
-->
<jar destfile="jettylib/commons-logging.jar" filesetmanifest="mergewithoutmain" >
<zipfileset excludes="META-INF/LICENSE.txt META-INF/NOTICE.txt" src="../../installer/lib/launch4j/lib/commons-logging.jar" />
</jar>
<ant target="copyTomcatLib" />
</target>
<!-- Tomcat util jar.
As of Tomcat 6.0.39, the deployer does not contain some classes that are required
to precompile jsps with tags (SusiDNS and i2p-bote).
These classes are in the main Tomcat package, in lib/tomcat-coyote.jar.
As the jar is 800 KB and we only need 12 KB of that, we extract the required classes
to a new jar, created and checked in using this target.
Apparently this is only required for precompilation of jsps, so this is put in
with the JspC compiler jasper-runtime.jar below.
-->
<target name="buildTomcatUtilJar" >
<!-- take only what we need from the tomcat-coyote jar -->
<jar destfile="${tomcat2.lib.small}/tomcat-coyote-util.jar" >
<zipfileset src="${tomcat2.lib}/tomcat-coyote.jar"
includes="org/apache/tomcat/util/descriptor/* org/apache/tomcat/util/res/*" />
</jar>
</target>
<!-- Tomcat.
The glassfish jars bundled in Jetty 6 are way too old.
For compatibility with very old I2P installations where the classpath
was set individually in wrapper.config, we rename and combine the jars as follows:
jasper.jar : jasper-runtime.jar
jasper-el.jar + el-api.jar : commons-el.jar
tomcat-juli.jar : Add to commons-logging.jar
empty jar : jasper-compiler.jar
Also, take NOTICE and LICENSE out of each one, we bundle those separately.
Not as of Jetty 8 (using from Jetty):
servlet-api.jar + jsp-api.jar : javax.servlet.jar
If we go to Tomcat 7:
tomcat-api.jar + tomcat-util.jar: Add to javax.servlet.jar (as of Tomcat 7 / Jetty 8)
-->
<target name="copyTomcatLib" >
<jar destfile="jettylib/jasper-runtime.jar" filesetmanifest="merge" >
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper.jar" />
<zipfileset src="${tomcat2.lib.small}/tomcat-coyote-util.jar" />
</jar>
<jar destfile="jettylib/commons-el.jar" duplicate="preserve" filesetmanifest="merge" >
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/jasper-el.jar" />
<zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/el-api.jar" />
</jar>
<!--
<jar destfile="jettylib/javax.servlet.jar" duplicate="preserve" filesetmanifest="mergewithoutmain" >
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/servlet-api.jar" />
<zipfileset excludes="META-INF/**/*" src="${tomcat.lib}/jsp-api.jar" />
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-api.jar" />
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-util.jar" />
</jar>
-->
<!-- Ant bug, don't set update and filesetmanifest or the update doesn't happen,
Their bug tracker claims fixed in 1.8.0 but broken for me in 1.8.1
-->
<jar destfile="jettylib/commons-logging.jar" update="true" >
<zipfileset excludes="META-INF/LICENSE META-INF/NOTICE" src="${tomcat.lib}/tomcat-juli.jar" />
</jar>
<jar destfile="jettylib/jasper-compiler.jar" >
<manifest>
<attribute name="Note" value="Intentionally empty" />
</manifest>
</jar>
</target>
<target name="build" depends="jar" />
<target name="builddep" />
<condition property="depend.available">
<typefound name="depend" />
</condition>
<target name="depend" if="depend.available">
<depend
cache="../../build"
srcdir="./java/src"
destdir="./build/obj" >
<classpath>
<pathelement location="../../../core/java/build/i2p.jar" />
<pathelement location="./jettylib/commons-logging.jar" />
<pathelement location="./jettylib/org.mortbay.jetty.jar" />
<pathelement location="./jettylib/javax.servlet.jar" />
<pathelement location="./jettylib/jetty-http.jar" />
<pathelement location="./jettylib/jetty-io.jar" />
<pathelement location="./jettylib/jetty-security.jar" />
<pathelement location="./jettylib/jetty-util.jar" />
<pathelement location="./jettylib/jetty-xml.jar" />
</classpath>
</depend>
</target>
<target name="compile" depends="builddep, ensureJettylib, depend" >
<mkdir dir="./build" />
<mkdir dir="./build/obj" />
<javac
srcdir="./java/src"
debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
destdir="./build/obj"
includeAntRuntime="false"
classpath="../../core/java/build/i2p.jar:./jettylib/commons-logging.jar:./jettylib/javax.servlet.jar:./jettylib/org.mortbay.jetty.jar:./jettylib/jetty-http.jar:./jettylib/jetty-io.jar:./jettylib/jetty-security.jar:./jettylib/jetty-util.jar:./jettylib/jetty-xml.jar" >
<compilerarg line="${javac.compilerargs}" />
</javac>
</target>
<target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
<exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<arg value="." />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
</target>
<!-- With Jetty 5 we replaced classes in the jar, but with Jetty 6 we
put our stuff in its own jar so we can work with standard Jetty 6 packages
-->
<target name="jar" depends="compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
<!-- set if unset -->
<property name="workspace.changes.tr" value="" />
<!-- old jetty 5 classes blow up the build if you forgot to do distclean -->
<delete dir="build/obj/org" />
<copy todir="build/obj" file="resources/log4j.properties" />
<jar destfile="./jettylib/jetty-i2p.jar" basedir="./build/obj" includes="**/*.class log4j.properties" >
<manifest>
<attribute name="Built-By" value="${build.built-by}" />
<attribute name="Build-Date" value="${build.timestamp}" />
<attribute name="Base-Revision" value="${workspace.version}" />
<!-- needed by JettyStart for pre-0.7.5 wrapper.config -->
<attribute name="Class-Path" value="jetty-deploy.jar jetty-xml.jar" />
<attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
</manifest>
</jar>
</target>
<target name="jarUpToDate">
<uptodate property="jar.uptodate" targetfile="jettylib/jetty-i2p.jar" >
<srcfiles dir= "build/obj" includes="**/*.class" />
</uptodate>
<condition property="shouldListChanges" >
<and>
<not>
<isset property="jar.uptodate" />
</not>
<isset property="mtn.available" />
</and>
</condition>
</target>
<target name="clean" >
<delete dir="./build" />
<delete file="${verified.filename}" />
</target>
<target name="cleandep" depends="clean" />
<target name="distclean" depends="clean">
<delete dir="./jettylib" />
<!--
<echo message="Not actually deleting the jetty libs (since they're so large)" />
-->
</target>
<target name="reallyclean" depends="distclean">
</target>
<target name="totallyclean" depends="clean">
<delete dir="./jettylib" />
<delete file="${jetty.filename}" />
</target>
<target name="javadoc" >
<available property="jetty.zip.available" file="${jetty.filename}" type="file" />
<available property="jetty.zip.javadocExtracted" file="build/javadoc" type="dir" />
<ant target="fetchJettylib" />
<ant target="verifyJettylib" />
<ant target="extractJavadoc" />
</target>
<target name="extractJavadoc" unless="jetty.zip.javadocExtracted" >
<mkdir dir="./build" />
<mkdir dir="./build/javadoc" />
<unzip src="${jetty.filename}" dest="./build/javadoc" >
<patternset>
<include name="${jetty.base}/javadoc/" />
</patternset>
<mapper type="glob" from="${jetty.base}/javadoc/*" to="javadoc/*" />
</unzip>
</target>
</project>