210 lines
9.2 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<project
xmlns:j="jelly:core"
xmlns:util="jelly:util"
xmlns:x="jelly:xml"
xmlns:ant="jelly:ant"
xmlns:doc="doc"
xmlns:maven="jelly:maven">
<goal name="cruisecontrol" prereqs="cruisecontrol:configure"/>
<!--==================================================================-->
<!-- Validate necessary properties for Cruise Control -->
<!--==================================================================-->
<goal name="cruisecontrol:validate" prereqs="scm:validate">
<j:set var="cruisecontrolHomeX" value="${maven.cruisecontrol.home}X"/>
<j:set var="ccHome" value="${maven.cruisecontrol.home}" />
<j:if test="${cruisecontrolHomeX == 'X'}">
<ant:fail>You must specify maven.cruisecontrol.home</ant:fail>
</j:if>
<j:set var="nagEmail" value="${pom.build.nagEmailAddress}" />
<j:if test="${empty(nagEmail)}">
<ant:fail>You must specify pom.build.nagEmailAddress</ant:fail>
</j:if>
<j:set var="defaultSuffix" value="${maven.cruisecontrol.mail.defaultsuffix}" />
<j:if test="${defaultSuffix == 'DEFAULT_SUFFIX_NOT_SET'}">
<util:tokenize var="tokens" delim="@">${pom.build.nagEmailAddress}</util:tokenize>
<j:set var="maven.cruisecontrol.mail.defaultsuffix" value="@${tokens[1]}" />
</j:if>
<!-- Compute the SCM URL to use. Note: IMO this should be done by the SCM plugin who
should provide a URL with this information for us to use -->
<maven:pluginVar var="method" plugin="maven-scm-plugin" property="maven.scm.method"/>
<j:if test="${method == 'cvs'}">
<maven:pluginVar var="root" plugin="maven-scm-plugin" property="maven.scm.cvs.root"/>
<maven:pluginVar var="module" plugin="maven-scm-plugin" property="maven.scm.cvs.module"/>
<j:set var="url" value="${root}"/>
</j:if>
<j:if test="${method == 'svn'}">
<maven:pluginVar var="root" plugin="maven-scm-plugin" property="maven.scm.svn.root"/>
<j:set var="url" value="${root}"/>
</j:if>
<!-- Compute the merge directory automatically if not specified by the user -->
<maven:makeRelativePath var="relativeMavenBuildDir" basedir="${basedir}"
path="${maven.build.dir}" separator="/"/>
<maven:property var="maven.cruisecontrol.logs.mergedirectory"
name="maven.cruisecontrol.logs.mergedirectory"
defaultValue="${maven.cruisecontrol.checkout.dir}/${pom.artifactId}/${relativeMavenBuildDir}/test-reports/"/>
</goal>
<!--==================================================================-->
<!-- Update a configuration file for Cruise Control -->
<!-- Will add or update this project's section -->
<!--==================================================================-->
<goal name="cruisecontrol:configure"
description="Update a Cruise Control configuration file with this project"
prereqs="cruisecontrol:validate">
<j:choose>
<j:when test="${systemScope['os.name'].startsWith('Windows')}">
<j:set var="mavenScript" value="${maven.cruisecontrol.mavenhome}/bin/maven.bat"/>
</j:when>
<j:otherwise>
<j:set var="mavenScript" value="${maven.cruisecontrol.mavenhome}/bin/maven"/>
</j:otherwise>
</j:choose>
<x:parse var="doc"><cruisecontrol></cruisecontrol></x:parse>
<util:available file="${maven.cruisecontrol.config}">
<util:file var="inputFile" name="${maven.cruisecontrol.config}" />
<x:parse var="doc" xml="${inputFile}" />
</util:available>
<!-- Question: Why is the tmp file required? Is it to prevent CC reloading
the config.xml during the generation? If so we need to comment this as
it's not obvious... -->
<ant:mkdir dir="${maven.cruisecontrol.build.dir}" />
<j:set
var="tempConfigFile"
value="${maven.cruisecontrol.build.dir}/config-temp.xml" />
<j:set
var="stylesheet"
value="file:${maven.cruisecontrol.template}" />
<j:file name="${tempConfigFile}" outputMode="xml" prettyPrint="yes">
<j:include uri="${stylesheet.toString()}" />
</j:file>
<ant:copy file="${tempConfigFile}" tofile="${maven.cruisecontrol.config}" />
<ant:delete file="${tempConfigFile}"/>
</goal>
<!--==================================================================-->
<!-- Run Cruise Control -->
<!--==================================================================-->
<goal name="cruisecontrol:run"
description="Run Cruise Control"
prereqs="cruisecontrol:validate">
<!-- Verify if work directory exists -->
<util:file var="workDirAsFile" name="${maven.cruisecontrol.work.dir}"/>
<j:choose>
<j:when test="${workDirAsFile.exists()}">
<ant:java jar="${maven.cruisecontrol.home}/main/dist/cruisecontrol.jar"
fork="true" dir="${maven.cruisecontrol.work.dir}">
<arg line="-projectname ${pom.artifactId}"/>
</ant:java>
</j:when>
<j:otherwise>
<ant:echo>You must have a work directory (${maven.cruisecontrol.work.dir}) set up before trying to run Cruisecontrol.</ant:echo>
</j:otherwise>
</j:choose>
</goal>
<!--==================================================================-->
<!-- Install the generated CruiseControl configuration on the same -->
<!-- machine in the ${maven.cruisecontrol.work.dir} directory. -->
<!--==================================================================-->
<goal name="cruisecontrol:install-local" prereqs="cruisecontrol:configure"
description="Perform a local installation of the generated CruiseControl configuration">
<!-- Only deploy if the work dir property has been set to a location
different than the default -->
<j:choose>
<j:when test="${!context.getVariable('maven.cruisecontrol.work.dir').equals(context.getVariable('maven.cruisecontrol.build.dir'))}">
<ant:mkdir dir="${maven.cruisecontrol.work.dir}"/>
<ant:copy tofile="${maven.cruisecontrol.work.dir}/config.xml"
file="${maven.cruisecontrol.config}"/>
</j:when>
<j:otherwise>
<ant:echo>You need to customize maven.cruisecontrol.work.dir to the real location</ant:echo>
</j:otherwise>
</j:choose>
</goal>
<goal name="cruisecontrol:checkout">
<maven:set plugin="maven-scm-plugin" property="maven.scm.checkout.dir"
value="${maven.cruisecontrol.checkout.dir}"/>
<!-- This needs SCM 1.5 and it needs support for the URL notation with
the module specified after a colon or to find another way to
get the module
<attainGoal name="scm:checkout"/>
-->
</goal>
<!--==================================================================-->
<!-- Configure the CruiseControl Webapp WAR and generate a fully -->
<!-- configured WAR ready to be used. -->
<!--==================================================================-->
<goal name="cruisecontrol:configure-war" prereqs="cruisecontrol:validate"
description="Generate a configured CruiseControl Webapp WAR">
<ant:unwar src="${maven.cruisecontrol.home}/reporting/jsp/dist/cruisecontrol.war"
dest="${maven.cruisecontrol.build.dir}/cruisecontrolwar"/>
<!-- Modify the web.xml file -->
<ant:replace file="${maven.cruisecontrol.build.dir}/cruisecontrolwar/WEB-INF/web.xml"
token="&lt;param-value&gt;logs&lt;/param-value&gt;"
value="&lt;param-value&gt;${maven.cruisecontrol.logs.dir}&lt;/param-value&gt;"/>
<ant:replace file="${maven.cruisecontrol.build.dir}/cruisecontrolwar/WEB-INF/web.xml"
token="&lt;param-value&gt;status.txt&lt;/param-value&gt;"
value="&lt;param-value&gt;${maven.cruisecontrol.currentbuildstatus.filename}&lt;/param-value&gt;"/>
<ant:war destfile="${maven.cruisecontrol.build.dir}/cruisecontrol.war"
basedir="${maven.cruisecontrol.build.dir}/cruisecontrolwar"
webxml="${maven.cruisecontrol.build.dir}/cruisecontrolwar/WEB-INF/web.xml"
excludes="**/web.xml"/>
</goal>
<goal name="maven-cruisecontrol-plugin:report">
<!-- TODO: download and transform instead of linking to it -->
</goal>
<goal name="maven-cruisecontrol-plugin:register">
<doc:registerReport
name="CC Build Results"
pluginName="maven-cruisecontrol-plugin"
externalLink="${maven.cruisecontrol.buildresults.url}"
description="See the cruise control build results page for this project." />
</goal>
<goal name="maven-cruisecontrol-plugin:deregister">
<doc:deregisterReport name="CC Build Results"/>
</goal>
</project>