128 lines
4.6 KiB
XML
128 lines
4.6 KiB
XML
<project name="chapter1-ant" default="run" xmlns:ivy="antlib:org.apache.ivy.ant">
|
|
|
|
<!-- ==========================================================
|
|
PROPERTIES RELATED TO IVY, AND VARIOUS DIRECTORY LOCATIONS
|
|
========================================================== -->
|
|
<property name="ivy.install.version" value="2.3.0-rc1" />
|
|
<property name="ivy.jar.dir" value="${basedir}/ivy" />
|
|
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
|
|
|
|
<property name="src.dir" value="src" />
|
|
<property name="web.dir" value="web" />
|
|
<property name="lib.dir" value="lib" />
|
|
<property name="jetty.lib.dir" value="jetty-lib" />
|
|
<property name="build.dir" value="target" />
|
|
<property name="dist.dir" value="dist" />
|
|
|
|
<path id="lib.path.id">
|
|
<fileset dir="${lib.dir}" />
|
|
<fileset dir="${jetty.lib.dir}" />
|
|
</path>
|
|
<path id="jetty.plugin.classpath">
|
|
<fileset dir="jetty-lib" includes="*.jar"/>
|
|
</path>
|
|
|
|
<!-- ==============================
|
|
MAIN DEFAULT TARGET
|
|
============================== -->
|
|
|
|
<target name="run" depends="clean, install-ivy, resolve" description="--> setup Ivy if needed, resolve dependencies, compile and run the project">
|
|
|
|
<echo message="COMPILING JAVA CLASSES..."/>
|
|
<mkdir dir="${build.dir}/WEB-INF/classes" />
|
|
<javac srcdir="${src.dir}" destdir="${build.dir}/WEB-INF/classes" classpathref="lib.path.id" includeantruntime="false" />
|
|
|
|
<echo message="COPYING RESOURCES..."/>
|
|
<copy todir="${build.dir}/WEB-INF/classes">
|
|
<fileset dir="${src.dir}" excludes="**/*.java"/>
|
|
</copy>
|
|
<copy todir="${build.dir}">
|
|
<fileset dir="${web.dir}" />
|
|
</copy>
|
|
|
|
<echo message="COPYING LIBRARIES..."/>
|
|
<mkdir dir="${build.dir}/WEB-INF/lib" />
|
|
<copy todir="${build.dir}/WEB-INF/lib">
|
|
<fileset dir="${lib.dir}" />
|
|
</copy>
|
|
|
|
<echo message="BUILDING A WAR FILE..."/>
|
|
<mkdir dir="${dist.dir}" />
|
|
<jar jarfile="${dist.dir}/vaporware.war" basedir="${build.dir}" />
|
|
|
|
<echo message="STARTING THE EMBEDDED SERVER..."/>
|
|
<jetty tempDirectory="jetty-temp">
|
|
<webApp name="vaporware" warfile="dist/vaporware.war" contextpath="/">
|
|
<attributes>
|
|
<attribute name="org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern" value=".*/.*jsp-api-[^/]*\.jar$|.*/.*jsp-[^/]*\.jar$|.*/.*taglibs[^/]*\.jar$"/>
|
|
</attributes>
|
|
</webApp>
|
|
</jetty>
|
|
|
|
<echo message="MAIN TARGET COMPLETED" />
|
|
|
|
</target>
|
|
|
|
|
|
<!-- ==============================
|
|
IVY-RELATED TARGETS
|
|
============================== -->
|
|
|
|
<!-- Download Ivy from web site so that it can be used even without any special installation -->
|
|
<target name="download-ivy" unless="skip.download">
|
|
<mkdir dir="${ivy.jar.dir}"/>
|
|
<echo message="installing ivy..."/>
|
|
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
|
|
dest="${ivy.jar.file}" usetimestamp="true"/>
|
|
</target>
|
|
|
|
<!-- This target is not necessary if you put ivy.jar in your ant lib directory -->
|
|
<target name="install-ivy" depends="download-ivy" description="--> install ivy">
|
|
<path id="ivy.lib.path">
|
|
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
|
|
</path>
|
|
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
|
|
</target>
|
|
|
|
<!-- Download the dependencies from "ivy.xml" to the "lib" subdirectory -->
|
|
<target name="resolve" description="--> retreive dependencies with ivy">
|
|
<ivy:retrieve/>
|
|
</target>
|
|
|
|
|
|
<!-- ==============================
|
|
JETTY-RELATED TARGET
|
|
============================== -->
|
|
|
|
<taskdef classpathref="jetty.plugin.classpath" resource="tasks.properties" loaderref="jetty.loader" />
|
|
|
|
<target name="jetty.run">
|
|
<jetty />
|
|
</target>
|
|
|
|
|
|
<!-- ==============================
|
|
CLEANUP-RELATED TARGETS
|
|
============================== -->
|
|
|
|
<!-- Cleanup files generated by previous builds -->
|
|
<target name="clean" description="--> clean the project">
|
|
<delete includeemptydirs="true" quiet="true">
|
|
<fileset dir="${dist.dir}" />
|
|
<fileset dir="${build.dir}" />
|
|
<fileset dir="${lib.dir}" />
|
|
<fileset dir="jetty-temp" />
|
|
</delete>
|
|
</target>
|
|
|
|
<!-- Remove the Ivy installation -->
|
|
<target name="clean-ivy" description="--> clean the ivy installation">
|
|
<delete dir="${ivy.jar.dir}"/>
|
|
</target>
|
|
|
|
<!-- Purge all the downloaded dependencies in your Ivy cache (i.e. the "~/.ivy2/cache" directory) -->
|
|
<target name="clean-cache" depends="install-ivy" description="--> clean the ivy cache">
|
|
<ivy:cleancache />
|
|
</target>
|
|
</project>
|