maven-plugins/scm/plugin.jelly

547 lines
21 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 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:i="jelly:interaction"
xmlns:t="scm:transform"
xmlns:c="changes:transform"
xmlns:define="jelly:define"
xmlns:ant="jelly:ant"
xmlns:scm="scm"
xmlns:util="jelly:util"
xmlns:maven="jelly:maven"
xmlns:r="jelly:org.apache.maven.plugins.scm.release.jelly.ReleaseTagLibrary">
<define:taglib uri="scm">
<define:jellybean
name="checkout"
method="checkout"
className="org.apache.maven.plugins.scm.ScmBean"
/>
<define:jellybean
name="update"
method="update"
className="org.apache.maven.plugins.scm.ScmUpdateBean"
/>
<define:jellybean
name="tag"
method="tag"
className="org.apache.maven.plugins.scm.ScmBean"
/>
<define:jellybean
name="status"
method="status"
className="org.apache.maven.plugins.scm.ScmStatusBean"
/>
<define:jellybean
name="checkin"
method="checkin"
className="org.apache.maven.plugins.scm.ScmCheckinBean"
/>
<define:jellybean
name="diff"
method="diff"
className="org.apache.maven.plugins.scm.ScmDiffBean"
/>
<define:jellybean
name="add"
method="add"
className="org.apache.maven.plugins.scm.ScmAddBean"
/>
</define:taglib>
<define:taglib uri="scm:transform">
<define:tag name="release-version">
<r:release-version
version="${version}"
tag="${tag}"
transformer="transformer"
transformations="transformations"/>
<j:set var="required" value="${transformer.transformRequired()}" />
<j:if test="${required}">
<ant:echo>Updating POM with version ${version}; tag ${tag}</ant:echo>
<!-- Set default encoding if not set. -->
<j:if test="${encoding == null}">
<j:set var="encoding" value="${maven.docs.outputencoding}" />
</j:if>
${transformer.transformNodes()}
${transformer.write(encoding)}
</j:if>
</define:tag>
</define:taglib>
<goal name="scm:find-connection">
<j:set var="scmConnection" value="${maven.scm.url}" />
<j:if test="${scmConnection == null}">
<j:set var="checkValue" value="${maven.scm.ignore.pom.developerConnection}"/>
<j:if test="${!checkValue}">
<j:set var="value" value="${pom.repository.developerConnection}"/>
<j:if test="${!empty(value)}">
<j:set var="scmConnection" value="${pom.repository.developerConnection}" />
</j:if>
</j:if>
</j:if>
<j:if test="${scmConnection == null}">
<j:set var="value" value="${pom.repository.connection}"/>
<j:if test="${!empty(value)}">
<j:set var="scmConnection" value="${pom.repository.connection}" />
</j:if>
</j:if>
<j:if test="${scmConnection == null}">
<j:if test="${scmMethod == 'cvs'}">
<j:set var="value" value="${maven.scm.cvs.root}" />
<j:if test="${!empty(value)}">
<ant:echo>DEPRECATED: the maven.scm.cvs.root property is deprecated. Please specify maven.scm.url</ant:echo>
<j:set var="scmConnection" value="scm:cvs${maven.scm.cvs.root}:${maven.scm.cvs.module}" />
</j:if>
</j:if>
</j:if>
<ant:echo>Using connection: ${scmConnection}</ant:echo>
</goal>
<goal name="scm:checkout" prereqs="scm:find-connection"
description="Checkout a project from SCM">
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<j:set var="msg" value="Checking out ${scmConnection}"/>
<j:set var="value" value="${maven.scm.tag}"/>
<j:if test="${!empty(value)}">
<j:set var="msg" value="${msg}; using tag: ${value}" />
</j:if>
<ant:echo>${msg}</ant:echo>
<scm:checkout var="checkoutBean" url="${scmConnection}" workingDirectory="${maven.scm.checkout.dir}" tag="${maven.scm.tag}" tagBase="${maven.scm.svn.tag.base}" username="${maven.scm.username}" password="${maven.scm.password}" />
</goal>
<goal name="scm:bootstrap" prereqs="scm:checkout" description="Boostrap a project from the SCM">
<ant:echo>Bootstrapping from ${checkoutBean.checkoutDirectory}/project.xml with goals ${maven.scm.bootstrap.goals}</ant:echo>
<j:set var="pomDir" value="${maven.scm.bootstrap.pom.dir}" />
<j:set var="dir" value="${checkoutBean.checkoutDirectory}" />
<j:if test="${!empty(pomDir)}">
<j:set var="dir" value="${dir}/${pomDir}" />
</j:if>
<maven:maven
descriptor="${dir}/project.xml"
goals="${maven.scm.bootstrap.goals}"
ignoreFailures="false"
/>
</goal>
<goal name="scm:update" prereqs="scm:find-connection" description="Update the project in the current directory from SCM">
<ant:echo>Updating from SCM</ant:echo>
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<scm:update
url="${scmConnection}"
workingDirectory="${basedir}"
includes="${maven.scm.src.includes}"
excludes="${maven.scm.src.excludes}"
username="${maven.scm.username}"
password="${maven.scm.password}" />
</goal>
<goal name="scm:tag" prereqs="scm:find-connection" description="Tag the project in the current directory in SCM">
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<j:set var="scmTag" value="${maven.scm.tag}"/>
<j:if test="${scmTag == null}">
<ant:fail>You must specify an SCM tag to apply</ant:fail>
</j:if>
<ant:echo>Tagging ${scmConnection} with ${maven.scm.tag}</ant:echo>
<scm:tag url="${scmConnection}" workingDirectory="${basedir}" tag="${maven.scm.tag}" tagBase="${maven.scm.svn.tag.base}" username="${maven.scm.username}" password="${maven.scm.password}" />
</goal>
<goal name="scm:checkin" prereqs="scm:find-connection" description="Checkin a set of files in the current directory of SCM" >
<ant:echo>Checkin files to SCM</ant:echo>
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<scm:checkin
url="${scmConnection}"
workingDirectory="${basedir}"
username="${maven.scm.username}"
password="${maven.scm.password}"
excludes="${maven.scm.src.excludes}"
includes="${maven.scm.src.includes}"
message="${maven.scm.message}"
tag="${maven.scm.tag}" />
</goal>
<goal name="scm:add" prereqs="scm:find-connection" description="Add a set of files in the current directory of SCM" >
<ant:echo>Add files to SCM</ant:echo>
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<scm:add
url="${scmConnection}"
workingDirectory="${basedir}"
username="${maven.scm.username}"
password="${maven.scm.password}"
excludes="${maven.scm.src.excludes}"
includes="${maven.scm.src.includes}" />
</goal>
<goal name="scm:status" prereqs="scm:find-connection" description="Query for status in the current directory of SCM" >
<ant:echo>Query for status</ant:echo>
<j:if test="${scmConnection == null}">
<ant:fail>You must specify an SCM URL to connect to</ant:fail>
</j:if>
<scm:status
url="${scmConnection}"
workingDirectory="${basedir}"
username="${maven.scm.username}"
password="${maven.scm.password}" />
</goal>
<!-- TODO: change prereqs to scm:find-connection only -->
<goal name="scm:perform-release" prereqs="scm:parse-connection,scm:check-deprecated-cvs-vars"
description="Perform a release from SCM">
<j:if test="${scmConnection == null}">
<!-- TODO: remove these legacy methods -->
<j:if test="${scmMethod == 'cvs'}">
<j:set var="cvsRoot" value="${maven.scm.cvs.root}" />
<j:if test="${!empty(cvsRoot)}">
<ant:echo>DEPRECATED: use of maven.scm.cvs.root is deprecated</ant:echo>
<j:set var="module" value="${maven.scm.cvs.module}"/>
<j:if test="${empty(module)}">
<i:ask question="What CVS module are you releasing from?" answer="maven.scm.cvs.module"/>
</j:if>
<j:set var="scmConnection" value="scm:cvs${maven.scm.cvs.root}:${maven.scm.cvs.module}" />
</j:if>
</j:if>
<j:if test="${scmConnection == null}">
<i:ask question="What is the SCM URL you are releasing from?" answer="scmConnection" />
</j:if>
<j:if test="${scmConnection == null}">
<ant:fail>the SCM URL is required</ant:fail>
</j:if>
</j:if>
<j:set var="tag" value="${maven.scm.tag}"/>
<j:if test="${empty(tag)}">
<i:ask question="What tag are you releasing from?" answer="maven.scm.tag"/>
</j:if>
<j:set var="goals" value="${maven.scm.bootstrap.goals}"/>
<j:if test="${empty(goals)}">
<i:ask question="What goals are you using to build?" answer="goals" default="multiproject:deploy" />
<j:set var="maven.scm.bootstrap.goals" value="${goals.trim()}"/>
</j:if>
<attainGoal name="scm:bootstrap" />
</goal>
<!-- TODO: change prereqs to scm:find-connection only -->
<goal name="scm:prepare-release"
prereqs="scm:parse-connection,scm:check-deprecated-cvs-vars"
description="Prepare for a release in SCM">
<ant:echo>Verifying no modifications are present</ant:echo>
<scm:status var="scmStatusBean" url="${scmConnection}" workingDirectory="${basedir}" username="${maven.scm.username}" password="${maven.scm.password}" />
<j:set var="modifiedItems" value="${scmStatusBean.changedFiles}" />
<j:if test="${not empty modifiedItems}">
<ant:echo>Modified:</ant:echo>
<j:forEach var="item" items="${modifiedItems}">
<ant:echo>(${item.status}) ${item.path}</ant:echo>
</j:forEach>
<ant:fail>Cannot prepare a release - there are modifications outside of project.xml and changes.xml</ant:fail>
</j:if>
<j:if test="${tag_name != null}">
<ant:echo>DEPREACTED: Using tag_name directly is deprecated. Please use maven.scm.tag</ant:echo>
<j:set var="maven.scm.tag" value="${tag_name}" />
<j:unset var="tag_name" />
</j:if>
<j:set var="tag_name" value="${maven.scm.tag}" />
<j:if test="${empty(tag_name)}">
<i:ask
question="What is the new tag name?"
answer="tag_name"
default="${maven.scm.tag}"
/>
</j:if>
<j:set var="version_name" value="${maven.scm.version}" />
<j:if test="${empty(version_name)}">
<i:ask
question="What is the new version?"
answer="version_name"
default="${tag_name}"
/>
</j:if>
<!-- TODO: verify that the name is valid for a tag -->
<!-- Update project.xml -->
<t:release-version version="${version_name}" tag="${tag_name}" />
<!-- Update changes.xml if it exists -->
<j:set var="changesFilename" value="${maven.docs.src}/changes.xml" />
<util:file var="file" name="${changesFilename}"/>
<j:if test="${file.exists()}">
<c:release-version version="${version_name}" />
</j:if>
<j:set var="testMode" value="${maven.scm.testmode}" />
<j:choose>
<j:when test="${testMode == 'true'}">
<ant:echo> </ant:echo>
<ant:echo> WARNING: maven.scm.testmode is set to 'true'</ant:echo>
<ant:echo> Changes made above will NOT be committed and tagging the project will be skipped! </ant:echo>
<ant:echo> Please check project.xml and xdocs/changes.xml</ant:echo>
<ant:echo> Then either re-run scm:prepare-release with maven.scm.testmode=false</ant:echo>
<ant:echo> or manually commit the files and tag the source tree:</ant:echo>
<ant:echo> maven scm:tag -Dmaven.scm.svn.tag=${tag_name} -Dmaven.scm.url=${scmConnection}</ant:echo>
</j:when>
<j:otherwise>
<ant:echo>Committing descriptors</ant:echo>
<!-- No tag here - in this context it means the branch to commit to, and we want whatever this checkout current is on -->
<scm:checkin url="${scmConnection}" workingDirectory="${basedir}" includes="project.xml,xdocs/changes.xml" message="[maven-scm-plugin] prepare release ${version_name}" username="${maven.scm.username}" password="${maven.scm.password}" />
<ant:echo>Tagging source tree</ant:echo>
<scm:tag url="${scmConnection}" workingDirectory="${basedir}" tag="${tag_name}" tagBase="${maven.scm.svn.tag.base}" username="${maven.scm.username}" password="${maven.scm.password}" />
</j:otherwise>
</j:choose>
</goal>
<goal name="scm:create-patch" description="Create a patch file for changes single last SCM update" prereqs="scm:find-connection">
<ant:mkdir dir="${maven.scm.patch.dir}"/>
<scm:diff url="${scmConnection}" workingDirectory="${basedir}" patchFile="${maven.scm.patch.dir}/${maven.scm.patch.file}" username="${maven.scm.username}" password="${maven.scm.password}" />
<ant:echo>Patch created in ${maven.scm.patch.dir}/${maven.scm.patch.file}</ant:echo>
</goal>
<!--
DEPRECATED METHODS
-->
<goal name="scm:validate" prereqs="scm:parse-connection">
<j:choose>
<j:when test="${scmMethod == 'cvs'}">
<j:set var="cvsRoot" value="${maven.scm.cvs.root}"/>
<j:if test="${empty(cvsRoot)}">
<ant:fail>You must specify maven.scm.cvs.root</ant:fail>
</j:if>
<j:set var="cvsModule" value="${maven.scm.cvs.module}"/>
<j:if test="${empty(cvsModule)}">
<ant:fail>You must specify maven.scm.cvs.module</ant:fail>
</j:if>
</j:when>
<j:when test="${scmMethod == 'svn'}">
<j:set var="svnRoot" value="${maven.scm.svn.root}"/>
<j:if test="${empty(svnRoot)}">
<ant:fail>You must specify maven.scm.svn.root</ant:fail>
</j:if>
</j:when>
<j:otherwise>
<ant:fail>Unknown SCM method: '${maven.scm.method}'</ant:fail>
</j:otherwise>
</j:choose>
</goal>
<goal name="scm:checkout-project"
prereqs="scm:validate">
<ant:echo>DEPRECATED: please use scm:checkout</ant:echo>
<j:choose>
<j:when test="${scmMethod == 'cvs'}">
<attainGoal name="scm:cvs-checkout-project"/>
</j:when>
<j:otherwise>
<ant:fail>Unsupported scm type: ${scmMethod}</ant:fail>
</j:otherwise>
</j:choose>
</goal>
<j:set var="scmMethod" value="${maven.scm.method}"/>
<goal name="scm:parse-connection" prereqs="scm:find-connection">
<j:if test="${scmConnection != null}">
<j:set var="delim" value=":"/>
<j:if test="${scmConnection.length() gt 3}">
<j:set var="delim" value="${scmConnection.substring(3, 4)}"/>
</j:if>
<util:tokenize var="tokens" delim="${delim}">${scmConnection}</util:tokenize>
<j:if test="${tokens[0] != 'scm'}">
<ant:fail>Invalid repository connection format</ant:fail>
</j:if>
<j:set var="maven.scm.method" value="${tokens[1]}"/>
<j:set var="scmMethod" value="${maven.scm.method}"/>
<ant:echo>Using SCM method: ${scmMethod}</ant:echo>
<j:if test="${scmMethod == 'cvs'}">
<j:choose>
<j:when test="${tokens[2] == 'local'}">
<j:set var="maven.scm.cvs.root" value=":${tokens[2]}:${tokens[3]}"/>
<j:set var="maven.scm.cvs.module" value="${tokens[4]}"/>
</j:when>
<j:otherwise>
<j:set var="maven.scm.cvs.root" value=":${tokens[2]}:${tokens[3]}:${tokens[4]}"/>
<j:set var="maven.scm.cvs.module" value="${tokens[5]}"/>
</j:otherwise>
</j:choose>
<ant:echo>Using CVSROOT: ${maven.scm.cvs.root}</ant:echo>
<ant:echo>Using module: ${maven.scm.cvs.module}</ant:echo>
</j:if>
<j:if test="${scmMethod == 'svn'}">
<j:set var="maven.scm.svn.root" value="${tokens[2]}:${tokens[3]}"/>
<j:set var="svnModule" value="${tokens[4]}"/>
<j:if test="${!empty(svnModule)}">
<ant:echo>DEPRECATED: using ':' to separate a module in the SVN connection string is deprecated</ant:echo>
<j:set var="maven.scm.svn.root" value="${maven.scm.svn.root}/${svnModule}" />
</j:if>
<ant:echo>Using SVN repository: ${maven.scm.svn.root}</ant:echo>
</j:if>
</j:if>
</goal>
<goal name="scm:cvs-update-project" prereqs="scm:check-deprecated-cvs-vars">
<attainGoal name="scm:update" />
</goal>
<goal name="scm:cvs-checkout-project" prereqs="scm:check-deprecated-cvs-vars">
<attainGoal name="scm:checkout" />
</goal>
<goal name="scm:cvs-tag-project" prereqs="scm:check-deprecated-cvs-vars">
<ant:echo>DEPRECATED: please use scm:tag goal instead</ant:echo>
<attainGoal name="scm:tag" />
</goal>
<goal name="scm:check-deprecated-cvs-vars">
<j:set var="scmFlags" value="${maven.scm.cvs.update.flags}"/>
<j:if test="${!empty(scmFlags)}">
<!-- TODO: should/can it be passed to maven SCM? -->
<ant:echo>DEPRECATED: maven.scm.cvs.update.flags no longer used - ignored</ant:echo>
</j:if>
<j:set var="scmFlags" value="${maven.scm.cvs.checkout.flags}"/>
<j:if test="${!empty(scmFlags)}">
<!-- TODO: should/can it be passed to maven SCM? -->
<ant:echo>DEPRECATED: maven.scm.cvs.checkout.flags no longer used - ignored</ant:echo>
</j:if>
<j:set var="scmRsh" value="${maven.scm.rsh}" />
<j:if test="${!empty(scmRsh)}">
<!-- TODO: should/can it be passed to maven SCM? -->
<ant:echo>DEPRECATED: maven.scm.cvs.rsh no longer used - ignored</ant:echo>
</j:if>
<j:set var="scmTag" value="${maven.scm.cvs.sticky.tag}"/>
<j:if test="${!empty(scmTag)}">
<j:set var="scmTag" value="${maven.scm.tag}"/>
<j:if test="${empty(scmTag)}">
<ant:echo>DEPRECATED: maven.scm.cvs.sticky.tag replaced by maven.scm.tag</ant:echo>
<j:set var="maven.scm.tag" value="${maven.scm.cvs.sticky.tag}" />
</j:if>
</j:if>
<j:set var="scmPatchDir" value="${maven.scm.cvs.patch.dir}"/>
<j:if test="${!empty(scmPatchDir)}">
<ant:echo>DEPRECATED: maven.scm.cvs.patch.dir replaced by maven.scm.patch.dir</ant:echo>
<j:set var="maven.scm.patch.dir" value="${maven.scm.cvs.patch.dir}" />
</j:if>
<j:set var="scmPatchDir" value="${maven.scm.cvs.patch.file}"/>
<j:if test="${!empty(scmPatchFile)}">
<ant:echo>DEPRECATED: maven.scm.cvs.patch.file replaced by maven.scm.patch.file</ant:echo>
<j:set var="maven.scm.patch.file" value="${maven.scm.cvs.patch.file}" />
</j:if>
</goal>
<goal name="scm:bootstrap-project" prereqs="scm:checkout-project">
<ant:echo>DEPRECATED: please use the scm:bootstrap goal instead</ant:echo>
<j:set var="checkTagged" value="${maven.scm.check.tagged}"/>
<j:if test="${checkTagged}">
<j:set var="tag" value="${maven.scm.cvs.sticky.tag}"/>
<j:if test="${tag == 'HEAD'}">
<maven:pom var="project" projectDescriptor="${checkoutBean.checkoutDirectory}/${maven.scm.cvs.module}/project.xml"/>
<ant:echo>WARNING: you are releasing HEAD. This will overwrite any previous release versioned '${project.currentVersion}'.</ant:echo>
<i:ask
question="Are you sure (y/n)?"
answer="ok"
default="n"
/>
<j:if test="${ok != 'y'}">
<ant:fail>Cancelled by response '${ok}'</ant:fail>
</j:if>
</j:if>
</j:if>
<j:set var="pomDir" value="${maven.scm.bootstrap.pom.dir}" />
<j:if test="${empty(pomDir)}">
<j:set var="pomDir" value="." />
</j:if>
<maven:maven
descriptor="${pomDir}/project.xml"
goals="${maven.scm.bootstrap.goals}"
ignoreFailures="false"
/>
</goal>
<goal name="scm:update-project" prereqs="scm:validate">
<ant:echo>DEPRECATED: please use the scm:update goal instead</ant:echo>
<j:choose>
<j:when test="${scmMethod == 'cvs'}">
<attainGoal name="scm:cvs-update-project"/>
</j:when>
<j:otherwise>
<ant:fail>Unsupported scm type: ${scmMethod}</ant:fail>
</j:otherwise>
</j:choose>
</goal>
<goal name="scm:cvs-prepare-release">
<ant:echo>DEPRECATED: please use scm:prepare-release</ant:echo>
<attainGoal name="scm:prepare-release"/>
</goal>
<goal name="scm:cvs-create-patch" prereqs="scm:check-deprecated-cvs-vars">
<ant:echo>DEPRECATED: the scm:cvs-create-patch goal has been replaced by scm:create-patch</ant:echo>
<attainGoal name="scm:create-patch" />
</goal>
</project>