Show build.xml syntax highlighted
<!--
/********************************************************************************
* CruiseControl, a Continuous Integration Toolkit
* Copyright (c) 2007, ThoughtWorks, Inc.
* 200 E. Randolph, 25th Floor
* Chicago, IL 60601 USA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* + Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* + Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************************/
-->
<project name="cruise-dashboard" default="all.test.local">
<property name="build.dir" value="target" />
<property name="properties.dir" value="properties" />
<property name="ccmain.dist.dir" value="${basedir}/../../main/dist" />
<property name="dist.dir" value="dist" />
<property name="war.dir" value="${build.dir}/war" />
<property name="app.classes.dir" value="${war.dir}/WEB-INF/classes" />
<property name="test.classes.dir" value="${build.dir}/classes/test" />
<property name="functionaltest.classes.dir" value="${build.dir}/classes/functionaltest" />
<property name="src.dir" value="src" />
<property name="war.src.dir" value="webapp" />
<property name="resources.dir" value="resources" />
<property name="test.dir" value="test" />
<property name="unittest.dir" value="${test.dir}/unit" />
<property name="functionaltest.dir" value="${test.dir}/functional" />
<property name="reports.dir" value="${build.dir}/reports" />
<property name="emma.dir" location="target/emma" />
<property name="jsunit.dir" location="jsunit" />
<property name="checkstyle.cache" value="${build.dir}/checkstyle.cache"/>
<property name="checkstyle.config" value="../../common/checkstyle.xml"/>
<property environment="env"/>
<import file="checklicense.xml" />
<import file="../../common/checkstyle-build.xml"/>
<import file="jsunit/jsunit.xml" />
<path id="lib.classpath">
<fileset dir="${ccmain.dist.dir}" includes="cruisecontrol.jar" />
<fileset dir="${basedir}/lib" includes="**/*.jar" />
</path>
<path id="emma.lib.dir">
<fileset dir="${basedir}/lib" includes="**/emma*.jar" />
</path>
<path id="app.classpath">
<path refid="lib.classpath" />
<pathelement path="${app.classes.dir}" />
</path>
<path id="emma.classpath">
<path refid="lib.classpath" />
<pathelement path="${emma.dir}/classes" />
</path>
<fileset dir="lib" id="product.lib">
<include name="*.jar" />
</fileset>
<path id="product.lib.path">
<fileset refid="product.lib" />
</path>
<path id="test.classpath">
<path refid="emma.classpath" />
<path refid="app.classpath" />
<pathelement path="${test.classes.dir}" />
<pathelement path="${functionaltest.classes.dir}" />
<pathelement path="${war.src.dir}" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib.dir" />
<target name="-clean">
<delete dir="${emma.dir}/classes" quiet="true" />
<delete dir="${build.dir}" quiet="true" />
<delete dir="${app.classes.dir}" quiet="true" />
<delete dir="${jsunit.dir}/ccjs" quiet="true" />
<delete dir="${jsunit.dir}/logs" quiet="true" />
<delete dir="${war.src.dir}/compressed" quiet="true" />
</target>
<target name="-check-jdk">
<condition property="not.jdk1.5">
<not>
<equals arg1="${ant.java.version}" arg2="1.5" />
</not>
</condition>
</target>
<target name="-check-browser-path">
<available file="${env.BROWSER_PATH}" filepath="${env.BROWSER_PATH}" property="is.browser.found"></available>
</target>
<target name="-report-no-jsunit-tests" if="not.jdk1.5">
<echo>You are using an older jdk version, so functional testing with jsunit will be skipped.</echo>
</target>
<target name="-report-failed-to-find-browser" unless="is.browser.found">
<echo message="The browser you defined can not be found in destionation '${env.BROWSER_PATH}'."></echo>
</target>
<target name="-compile">
<fail>
<condition>
<not>
<available file="${ccmain.dist.dir}/cruisecontrol.jar" />
</not>
</condition>
The cruisecontrol.jar was not found at ${ccmain.dist.dir}/cruisecontrol.jar. Try running the main build first.
</fail>
<mkdir dir="${build.dir}" />
<mkdir dir="${app.classes.dir}" />
<javac destdir="${app.classes.dir}" classpathref="app.classpath" debug="true" source="1.4" target="1.4">
<src location="${src.dir}" />
</javac>
</target>
<target name="-compile-tests">
<mkdir dir="${test.classes.dir}" />
<mkdir dir="${functionaltest.classes.dir}" />
<javac destdir="${test.classes.dir}" classpathref="test.classpath" debug="true" failonerror="true" source="1.4" target="1.4">
<src location="${unittest.dir}" />
</javac>
<javac destdir="${functionaltest.classes.dir}" classpathref="test.classpath" debug="true" failonerror="true" source="1.4" target="1.4">
<src location="${functionaltest.dir}" />
</javac>
</target>
<target name="-unit-tests">
<mkdir dir="${reports.dir}" />
<mkdir dir="${test.classes.dir}/build" />
<junit printsummary="yes" dir="${basedir}" haltonfailure="true" fork="true" forkMode="once">
<classpath refid="test.classpath" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<jvmarg value="-Demma.coverage.out.file=${emma.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<formatter type="xml" />
<batchtest todir="${reports.dir}">
<fileset dir="${unittest.dir}">
<include name="**/*Test.java" />
<exclude name="**/AllTests.java" />
<exclude name="**/SpringBasedControllerTest.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="-functional-tests">
<mkdir dir="${reports.dir}" />
<junit printsummary="true" fork="true" haltonfailure="true" dir="${basedir}">
<classpath refid="test.classpath" />
<formatter type="xml" />
<test name="net.sourceforge.cruisecontrol.dashboard.jwebunittests.AllTests" todir="${reports.dir}" />
</junit>
</target>
<target name="-selenium.tests">
<mkdir dir="${reports.dir}" />
<junit printsummary="true" fork="true" haltonfailure="true" dir="${basedir}">
<classpath refid="test.classpath" />
<formatter type="xml" />
<test name="net.sourceforge.cruisecontrol.dashboard.seleniumtests.AllSeleniumTests" todir="${reports.dir}" />
</junit>
</target>
<target name="-copy.resources.web">
<mkdir dir="${war.dir}" />
<copy todir="${war.dir}">
<fileset dir="${war.src.dir}">
<exclude name="**/classes/**" />
</fileset>
</copy>
</target>
<target name="-checkstyle-main">
<checkstyle-macro
reportsdir="${reports.dir}"
configfile="${checkstyle.config}"
checkstylecache="${checkstyle.cache}"
testdir="${unittest.dir}">
<taskdef classpathref="lib.classpath" resource="checkstyletask.properties" />
</checkstyle-macro>
</target>
<target name="-war.production">
<mkdir dir="${dist.dir}" />
<war destfile="${dist.dir}/dashboard.war" webxml="${war.dir}/WEB-INF/web.xml" duplicate="preserve">
<fileset dir="${war.dir}">
<exclude name="**/applicationContext-development.xml" />
<exclude name="javascripts/*.js" />
</fileset>
<lib dir="${ccmain.dist.dir}">
<include name="cruisecontrol.jar" />
</lib>
<lib refid="product.lib" />
<lib dir="lib/buildtime">
<include name="jdom-1.0.jar" />
</lib>
<lib dir="lib">
<include name="licenses/*" />
</lib>
</war>
</target>
<target name="-war.development">
<mkdir dir="${dist.dir}" />
<war destfile="${dist.dir}/dashboard.war" webxml="${war.dir}/WEB-INF/web.xml" duplicate="preserve">
<fileset dir="${war.dir}">
<exclude name="javascripts" />
</fileset>
<filename name="${war.dir}/javascripts/all.js"/>
<classes dir="${test.classes.dir}" />
<lib dir="lib" />
</war>
</target>
<target name="-properties.production">
<copy todir="${app.classes.dir}" overwrite="true">
<fileset dir="${properties.dir}/src/" />
</copy>
</target>
<target name="-properties.development">
<copy todir="${app.classes.dir}">
<fileset dir="${properties.dir}/test/" />
</copy>
</target>
<target name="-start-jetty-server">
<java classname="net.sourceforge.cruisecontrol.dashboard.testhelpers.CruiseDashboardServer" fork="true">
<classpath refid="test.classpath" />
</java>
</target>
<target name="-start.jetty.server.with.sys">
<java classname="net.sourceforge.cruisecontrol.dashboard.testhelpers.CruiseDashboardServer" fork="true">
<sysproperty key="cc.home" value="${basedir}/test/data"/>
<sysproperty key="cc.artifacts" value="${basedir}/test/data/arbitrary_artifacts/artifacts"/>
<sysproperty key="cc.config.file" value="${basedir}/test/data/config.xml"/>
<sysproperty key="cc.config.forcebuild" value="enabled"/>
<classpath refid="test.classpath" />
</java>
</target>
<target name="-emma.instr">
<mkdir dir="${emma.dir}" />
<mkdir dir="${emma.dir}/classes" />
<property name="junit.fail.on.error" value="false" />
<emma enabled="true">
<instr instrpath="${app.classes.dir}" destdir="${emma.dir}/classes" metadatafile="${emma.dir}/metadata.emma" merge="true">
<filter excludes="net.sourceforge.cruisecontrol.dashboard.web.command.*" />
<filter excludes="net.sourceforge.cruisecontrol.dashboard.exception.*" />
<filter excludes="net.sourceforge.cruisecontrol.dashboard.testhelpers.*" />
<filter excludes="net.sourceforge.cruisecontrol.dashboard.seleniumtests.*" />
<filter excludes="net.sourceforge.cruisecontrol.dashboard.jwebunittests.*" />
</instr>
</emma>
</target>
<target name="-emma.reporting">
<emma enabled="true">
<report sort="+name" metrics="method:83,block:83,line:74,class:88">
<fileset dir="${emma.dir}">
<include name="*.emma" />
</fileset>
<xml outfile="${emma.dir}/coverage.xml" />
<html outfile="${emma.dir}/coverage.html" />
</report>
</emma>
</target>
<target name="-emma.check">
<loadfile property="emma.output" srcFile="${emma.dir}/coverage.html" />
<fail message="Your code coverage is too low.">
<condition>
<contains string="${emma.output}" substring="class="h"" casesensitive="false" />
</condition>
</fail>
</target>
<target name="-emma.clean">
<delete dir="${emma.dir}" />
</target>
<target name="-copy.compress.jsunit">
<copy todir="jsunit/compressed" overwrite="true">
<fileset dir="${war.src.dir}/compressed">
<include name="all.js" />
</fileset>
</copy>
</target>
<target name="-jsunit" unless="not.jdk1.5">
<echo message="${lib}" />
<echo message="${basedir}" />
<junit showoutput="true" haltonerror="true" haltonfailure="true">
<formatter type="plain" usefile="false" />
<classpath refid="classpath" />
<sysproperty key="browserFileNames" value="${browserFileNames}" />
<sysproperty key="description" value="${description}" />
<sysproperty key="closeBrowsersAfterTestRuns" value="${closeBrowsersAfterTestRuns}" />
<sysproperty key="logsDirectory" value="${logsDirectory}" />
<sysproperty key="port" value="${port}" />
<sysproperty key="resourceBase" value="${resourceBase}" />
<sysproperty key="timeoutSeconds" value="${timeoutSeconds}" />
<sysproperty key="url" value="${url}" />
<test name="net.jsunit.StandaloneTest" />
</junit>
</target>
<target name="-stop.selenium.server">
<get taskname="selenium-shutdown" src="http://localhost:4444/selenium-server/driver/?cmd=shutDown" dest="selenium-result.txt" ignoreerrors="true" />
</target>
<target name="-start.selenium.server">
<java jar="lib/buildtime/selenium-server.jar" fork="true" spawn="true">
<arg line="-timeout 30" />
</java>
<waitfor maxwait="1" maxwaitunit="minute" checkevery="1" checkeveryunit="second">
<socket server="localhost" port="4444" />
</waitfor>
</target>
<target name="-compress.js">
<taskdef name="jsmin" classname="org.inconspicuous.jsmin.JSMinTask" classpathref="test.classpath"></taskdef>
<concat destfile="${war.src.dir}/compressed/all.js">
<fileset file="${war.src.dir}/javascripts/prototype.js"/>
<fileset file="${war.src.dir}/javascripts/build_base_observer.js"/>
<fileset file="${war.src.dir}/javascripts/effects.js"/>
<fileset dir="${war.src.dir}/javascripts" includes="*.js" excludes="prototype.js,scriptaculous.js,build_base_executer.js,effects.js"/>
</concat>
<jsmin file="${war.src.dir}/compressed/all.js"/>
</target>
<target name="-compress.css">
<concat destfile="${war.src.dir}/compressed/all.css">
<fileset dir="${war.src.dir}/css" includes="*.css"/>
</concat>
</target>
<target name="--copy.compress.jsunit" depends="--compress, -copy.compress.jsunit" />
<target name="--jsunit" depends="--copy.compress.jsunit, -jsunit" />
<target name="--compile" depends="-clean, --compress, -copy.resources.web, -compile" />
<target name="--war.production" depends="-properties.production, -war.production" />
<target name="--war.development" depends="-properties.development, -war.development" />
<target name="--run.unit.tests" depends="--compile, -compile-tests, -properties.development, -unit-tests" />
<target name="--run.functional.tests" depends="--prepare.functional.tests, -functional-tests" />
<target name="--stat" depends="-emma.clean, --compile, -compile-tests,-properties.development, -emma.instr, -unit-tests, -emma.reporting, -emma.check" />
<target name="--start-jetty-server" depends="--package.development, -start.jetty.server.with.sys" />
<target name="--run.all.tests" depends="--check.license, --run.unit.tests, --run.functional.tests, -checkstyle-main" />
<target name="--package.production" depends="-clean, --compile, --war.production" />
<target name="--package.development" depends="-clean, --compile, -compile-tests, --war.production" />
<target name="--prepare.functional.tests" depends="--compile, -compile-tests, --war.development" />
<target name="--run.selenium.tests" depends="-start.selenium.server, -selenium.tests, -stop.selenium.server" />
<target name="--selenium" depends="--prepare.functional.tests, -start.selenium.server, -selenium.tests, -stop.selenium.server" />
<target name="--dist" depends="-clean, --run.all.tests, --war.production" />
<target name="--product" depends="--compile, --war.production" description="build and package war without testing" />
<target name="--compress" depends="-compress.js, -compress.css" description="compresses all the js and css files to speed up browser load" />
<target name="package.development" depends="--package.development" description="package for development" />
<target name="package.production" depends="--package.production" description="package application for production" />
<target name="ut" depends="--run.unit.tests" description="run all unit tests" />
<target name="ft" depends="--run.functional.tests" description="run all functional tests" />
<target name="start.server" depends="--start-jetty-server" description="start jetty server" />
<target name="all.test" depends="--run.all.tests" description="run unit tests and functional tests" />
<target name="all.test.local" depends="--run.all.tests, js.unit, --run.selenium.tests, -war.production" description="run unit tests and functional tests" />
<target name="clean" depends="-clean" description="clean all" />
<target name="stat" depends="--stat" description="generating the test coverage of source code" />
<target name="checkstyle" depends="-checkstyle-main" description="checkstyle" />
<target name="js.unit" depends="-check-jdk, -report-no-jsunit-tests, -check-browser-path, -report-failed-to-find-browser, --jsunit" description="run jsunit test" />
<target name="selenium" depends="--selenium" description="run selenium test" />
<target name="dist" depends="--dist" description="build and package war" />
<target name="product" depends="--product" description="build and package war without testing" />
<target name="compress" depends="--compress" description="compress the javascripts and css files" />
<target name="reload.jsunit" depends="--copy.compress.jsunit" description="refresh the javascript for testing in jsunit"/>
</project>
See more files for this project here