initial version of SCM plugin

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113910 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
brett 2003-08-31 07:00:23 +00:00
parent f115a120b6
commit e06bff2d6b
13 changed files with 759 additions and 0 deletions

19
scm/announcements/1.0.ann Normal file
View File

@ -0,0 +1,19 @@
The Maven team is pleased to announce the SCM plugin 1.0 release!
http://maven.apache.org/reference/plugins/scm/
The Maven SCM project helps perform automated tasks with your source control
management software.
This is the first release of the plugin, with support for CVS.
And in case you are wondering, the release process for the SCM plugin uses the
SCM plugin itself. We believe in eating our own dog food because it is
delicious! :)
You can download the SCM plugin here:
http://www.ibiblio.org/maven/maven/plugins/maven-scm-plugin-1.0.jar
Enjoy!
Brett

260
scm/plugin.jelly Normal file
View File

@ -0,0 +1,260 @@
<?xml version="1.0"?>
<project
xmlns:j="jelly:core"
xmlns:i="jelly:interaction"
xmlns:log="jelly:log"
xmlns:ant="jelly:ant"
xmlns:doc="doc"
xmlns:util="jelly:util"
xmlns:maven="jelly:maven">
<j:set var="scmMethod" value="${maven.scm.method}"/>
<!--==================================================================-->
<!-- Goal to validate SCM properties -->
<!--==================================================================-->
<goal name="scm:validate">
<j:set var="value" value="${pom.repository.connection}"/>
<j:if test="${!empty(value)}">
<!-- Use pom.repository.connection if present -->
<util:tokenize var="tokens" delim=":">${pom.repository.connection}</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}"/>
<log:info>Using SCM method: ${scmMethod}</log:info>
<j:if test="${scmMethod == 'cvs'}">
<j:set var="maven.scm.cvs.root" value=":${tokens[2]}:${tokens[3]}:${tokens[4]}"/>
<j:set var="maven.scm.cvs.module" value="${tokens[5]}"/>
<log:info>Using CVSROOT: ${maven.scm.cvs.root}</log:info>
<log:info>Using module: ${maven.scm.cvs.module}</log:info>
</j:if>
</j:if>
<j:choose>
<j:when test="${scmMethod == 'cvs'}">
<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:otherwise>
<ant:fail>Unknown SCM method: '${maven.scm.method}'</ant:fail>
</j:otherwise>
</j:choose>
</goal>
<!--==================================================================-->
<!-- Goal to checkout a project -->
<!--==================================================================-->
<goal name="scm:checkout-project"
prereqs="scm:validate"
description="Checkout a project">
<j:if test="${scmMethod == 'cvs'}">
<attainGoal name="scm:cvs-checkout-project"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Goal to bootstrap a project from SCM -->
<!--==================================================================-->
<goal name="scm:bootstrap-project"
description="Bootstrap a project from SCM"
prereqs="scm:checkout-project">
<maven:maven
descriptor="${maven.scm.bootstrap.pom.dir}/project.xml"
goals="${maven.scm.bootstrap.goals}"
ignoreFailures="false"
/>
</goal>
<!--==================================================================-->
<!-- Goal to update a project -->
<!--==================================================================-->
<goal name="scm:update-project"
prereqs="scm:validate"
description="Update a project from SCM">
<j:if test="${scmMethod == 'cvs'}">
<attainGoal name="scm:cvs-update-project"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Prepare Release -->
<!--==================================================================-->
<goal name="scm:prepare-release"
prereqs="scm:validate"
description="Prepare for a release in SCM">
<j:if test="${scmMethod == 'cvs'}">
<attainGoal name="scm:cvs-prepare-release"/>
</j:if>
</goal>
<!--==================================================================-->
<!-- Perform Release -->
<!-- TODO: we should be able to select what to deploy and so on, -->
<!-- tie in with multiproject-by-groupId idea -->
<!--==================================================================-->
<goal name="scm:perform-release"
description="Perform a release from SCM">
<!-- Setup variables -->
<j:choose>
<j:when test="${scmMethod == 'cvs'}">
<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="tag" value="${maven.scm.cvs.sticky.tag}"/>
<j:if test="${empty(tag)}">
<i:ask question="What CVS tag are you releasing from?" answer="maven.scm.cvs.sticky.tag"/>
</j:if>
</j:when>
<j:when test="${empty(scmMethod)}">
<ant:fail>You must specify maven.scm.method</ant:fail>
</j:when>
<j:otherwise>
<ant:fail>Unknown SCM method: ${scmMethod}</ant:fail>
</j:otherwise>
</j:choose>
<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="maven.scm.bootstrap.goals" default="multiproject:deploy" />
</j:if>
<!-- TODO: too slow pre-rc1!
<attainGoal name="scm:bootstrap-project" />
-->
<attainGoal name="scm:checkout-project" />
<!-- TODO: check tagged syntax ok with other SCM than CVS, including in docs -->
<j:set var="checkTagged" value="${maven.scm.check.tagged}"/>
<j:if test="${checkTagged}">
<!-- TODO: what about branch tags? Check <version>? What about cvs command for such? -->
<j:set var="tag" value="${maven.scm.cvs.sticky.tag}"/>
<j:if test="${tag == 'HEAD'}">
<maven:pom var="project" projectDescriptor="${maven.scm.checkout.dir}/${maven.scm.cvs.module}/project.xml"/>
<log:info>WARNING: you are releasing HEAD. This will overwrite any previous release versioned '${project.currentVersion}'.</log:info>
<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>
<ant:exec dir="${maven.scm.checkout.dir}/${maven.scm.cvs.module}" executable="maven" failonerror="true">
<ant:arg line="${maven.scm.bootstrap.goals}"/>
</ant:exec>
</j:if>
</goal>
<!--==================================================================-->
<!-- Checkout - CVS -->
<!--==================================================================-->
<goal name="scm:cvs-checkout-project">
<j:set var="msg" value="Checking out ${maven.scm.cvs.module}" />
<j:set var="value" value="${maven.scm.cvs.root}"/>
<j:if test="${!empty(value)}">
<j:set var="msg" value="${msg}; from CVSROOT: ${value}" />
</j:if>
<j:set var="value" value="${maven.scm.cvs.sticky.tag}"/>
<j:if test="${!empty(value)}">
<j:set var="msg" value="${msg}; using tag: ${value}" />
</j:if>
<ant:echo>${msg}</ant:echo>
<j:set var="maven.scm.bootstrap.pom.dir" value="${maven.scm.checkout.dir}/${maven.scm.cvs.module}"/>
<ant:delete dir="${maven.scm.bootstrap.pom.dir}"/>
<ant:mkdir dir="${maven.scm.bootstrap.pom.dir}"/>
<ant:cvs command="checkout ${maven.scm.cvs.checkout.flags}"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
dest="${maven.scm.checkout.dir}"
package="${maven.scm.cvs.module}"
tag="${maven.scm.cvs.sticky.tag}"
failonerror="true"
/>
</goal>
<!--==================================================================-->
<!-- Update - CVS -->
<!--==================================================================-->
<goal name="scm:cvs-update-project">
<ant:cvs command="update ${maven.scm.cvs.update.flags}"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
tag="${maven.scm.cvs.sticky.tag}"
failonerror="true"
/>
</goal>
<!--==================================================================-->
<!-- Prepare Release - CVS -->
<!-- TODO: this should be amalgamated with release plugin -->
<!--==================================================================-->
<goal name="scm:cvs-prepare-release">
<log:info>Verifying no modifications are present</log:info>
<!-- Need to move POM out of the way as mods there are allowed -->
<ant:copy file="project.xml" tofile="temp_project.xml" />
<ant:cvs command="update -C project.xml"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
failonerror="true"
/>
<ant:cvs command="tag -c dummy_tag"
noexec="true"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
failonerror="true"
/>
<i:ask
question="What is the new tag name?"
answer="tag_name"
default="${tag_name}"
/>
<i:ask
question="What is the new version?"
answer="version_name"
default="${tag_name}"
/>
<log:info>Verifying valid tag name</log:info>
<ant:cvs command="tag ${tag_name} project.xml"
noexec="true"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
failonerror="true"
/>
<ant:move file="temp_project.xml" tofile="project.xml" />
<log:info>Modifying POM with tag = ${tag_name}; version = ${version_name}</log:info>
<doc:jslFile
input="${basedir}/project.xml"
output="${basedir}/project.xml"
stylesheet="${plugin.resources}/pom-release.jsl"
outputMode="xml"
omitXmlDeclaration="false"
prettyPrint="true"
/>
<log:info>Committing new POM</log:info>
<ant:cvs command="commit -m '[maven-scm] prepare a release' project.xml"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
failonerror="true"
/>
<log:info>Tagging source tree</log:info>
<ant:cvs command="tag ${tag_name}"
quiet="${maven.scm.cvs.quiet}"
cvsRsh="${maven.scm.cvs.rsh}"
cvsRoot="${maven.scm.cvs.root}"
failonerror="true"
/>
</goal>
</project>

32
scm/plugin.properties Normal file
View File

@ -0,0 +1,32 @@
# Available settings currently only CVS
maven.scm.method=
# Directory to checkout to
maven.scm.checkout.dir=${basedir}/checkouts
# Goals to run on checkout when bootstrapping a project
maven.scm.bootstrap.goals=
# Directory under the checkout that contains the project.xml to run
maven.scm.bootstrap.pom.dir=
# check whether CVS tagged first, and warn
maven.scm.check.tagged=true
#===============
# CVS Properties
#===============
# Set to CVS RSH variable, or leave as is to use CVS_RSH from the environment
maven.scm.cvs.rsh=
# Set to CVS root, or leave as is to use CVSROOT from the environment
maven.scm.cvs.root=
# CVS module to check out, required
maven.scm.cvs.module=
# Flags after update. Default updates new directories and prunes empty ones
maven.scm.cvs.update.flags=-Pd
# Flags after checkout. Default prunes empty directories
maven.scm.cvs.checkout.flags=-P
# Sticky tag/branch to use. Default is trunk.
maven.scm.cvs.sticky.tag=
# Whether to use quiet mode
maven.scm.cvs.quiet=true

7
scm/project.properties Normal file
View File

@ -0,0 +1,7 @@
# -------------------------------------------------------------------
# P R O J E C T P R O P E R T I E S
# -------------------------------------------------------------------
maven.xdoc.date=left
maven.xdoc.version=${pom.currentVersion}
maven.license.licenseFile=${basedir}/../../../LICENSE.txt

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<jsl:stylesheet
select="$doc"
xmlns:jsl="jelly:jsl"
xmlns:j="jelly:core"
xmlns:x="jelly:xml"
xmlns:doc="doc"
trim="false">
<jsl:template match="project">
<x:copy select=".">
<jsl:applyTemplates />
</x:copy>
</jsl:template>
<jsl:template match="currentVersion">
<x:copy select=".">${version_name}</x:copy>
</jsl:template>
<jsl:template match="versions">
<x:copy select=".">
<version>
<id>${version_name}</id>
<name>${version_name}</name>
<tag>${tag_name}</tag>
</version>
<jsl:applyTemplates />
</x:copy>
</jsl:template>
<jsl:template match="version">
<j:set var="current_tag"><x:expr select="tag" /></j:set>
<j:if test="${current_tag != tag_name}">
<x:copyOf select="." />
</j:if>
</jsl:template>
<jsl:template match="*">
<x:copyOf select="." />
</jsl:template>
</jsl:stylesheet>

15
scm/xdocs/changes.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<document>
<properties>
<title>Changes</title>
<author email="brett@apache.org">Brett Porter</author>
</properties>
<body>
<release version="1.0" date="2003-08-31">
<action dev="brett" type="add">
Initial creation - support for CVS.
</action>
</release>
</body>
</document>

42
scm/xdocs/goals.xml Normal file
View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Maven Source Control Management Plug-in Goals</title>
</properties>
<body>
<goals>
<goal>
<name>scm:bootstrap-project</name>
<description>Bootstrap a project from SCM</description>
</goal>
<goal>
<name>scm:checkout-project</name>
<description>Checkout a project</description>
</goal>
<goal>
<name>scm:update-project</name>
<description>Update a project from SCM</description>
</goal>
<goal>
<name>scm:prepare-release</name>
<description>
Prepare a project for release from SCM. This checks all
changes are committed, and prompts for a tag and version
name to release the project with. It will update project.xml locally
and in the SCM system, as well as tagging the SCM as requested.
</description>
</goal>
<goal>
<name>scm:perform-release</name>
<description>
This task checks out the project from SCM at any location, from the
tag requested. It then builds a clean version of the code and deploys
it to the remote repository.
You can automate this using the appropriate properties, but for any
that are not provided you will be prompted for them.
</description>
</goal>
</goals>
</body>
</document>

24
scm/xdocs/navigation.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Maven Source Control Management Plug-in">
<title>Maven Source Control Management Plug-in</title>
<body>
<links>
<item href="http://maven.apache.org/" name="Maven">
</item>
</links>
<menu name="Overview">
<item href="/goals.html" name="Goals">
</item>
<item href="/properties.html" name="Properties">
</item>
</menu>
<menu name="Downloads">
<item name="SCM 1.0"
href="http://www.ibiblio.org/maven/maven/plugins/maven-scm-plugin-1.0.jar"/>
</menu>
<menu name="Releases">
<item name="Release 1.0" href="releases/v1.0/index.html"/>
</menu>
</body>
</project>

122
scm/xdocs/properties.xml Normal file
View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Maven Source Control Management Plug-in Properties</title>
</properties>
<body>
<section name="Maven Source Control Management Plug-in Settings">
<subsection name="General SCM Settings">
<table>
<tr>
<th>Property</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td>maven.scm.method</td>
<td>Yes</td>
<td>
<p>Default value is
<code>cvs</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.checkout.dir</td>
<td>Yes</td>
<td>
<p>Default value is
<code>${basedir}/checkouts</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.check.tagged</td>
<td>Yes</td>
<td>
<p>When <code>true</code>, you will be asked for confirmation if
you are attempting to release from <code>HEAD</code>.
Default value is <code>true</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.bootstrap.goals</td>
<td>No</td>
<td>
<p>Goals to call on the checked out project.</p>
</td>
</tr>
<tr>
<td>maven.scm.bootstrap.pom.dir</td>
<td>Yes</td>
<td>
<p>Where to find project.xml in the checked out project.</p>
</td>
</tr>
</table>
</subsection>
<subsection name="CVS Settings">
<table>
<tr>
<th>Property</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td>maven.scm.cvs.root</td>
<td>Yes</td>
<td>
<p>Default value is taken from CVSROOT in the environment.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.update.flags</td>
<td>Yes</td>
<td>
<p>Default value is
<code>-Pd</code>. Note that any environment settings
(eg .cvsrc) will also affect this.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.module</td>
<td>No</td>
<td>
<p>The CVS module to checkout</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.sticky.tag</td>
<td>Yes</td>
<td>
<p>Sticky tag to use when checking out or updating. Default is none.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.quiet</td>
<td>Yes</td>
<td>
<p>Default value is
<code>true</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.checkout.flags</td>
<td>Yes</td>
<td>
<p>Default value is
<code>-P</code>. Note that any environment settings
(eg .cvsrc) will also affect this.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.rsh</td>
<td>Yes</td>
<td>
<p>Default value is taken from CVS_RSH in the environment.</p>
</td>
</tr>
</table>
</subsection>
</section>
</body>
</document>

View File

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<document>
<properties>
<title>Changes</title>
<author email="brett@apache.org">Brett Porter</author>
</properties>
<body>
<release version="1.0" date="2003-08-31">
<action dev="brett" type="add">
Initial creation - support for CVS.
</action>
</release>
</body>
</document>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Maven Source Control Management Plug-in Goals</title>
</properties>
<body>
<goals>
<goal>
<name>scm:bootstrap-project</name>
<description>Bootstrap a project from SCM</description>
</goal>
<goal>
<name>scm:checkout-project</name>
<description>Checkout a project</description>
</goal>
<goal>
<name>scm:update-project</name>
<description>Update a project from SCM</description>
</goal>
<goal>
<name>scm:prepare-release</name>
<description>
Prepare a project for release from SCM. This checks all
changes are committed, and prompts for a tag and version
name to release the project with. It will update project.xml locally
and in the SCM system, as well as tagging the SCM as requested.
</description>
</goal>
<goal>
<name>scm:perform-release</name>
<description>
This task checks out the project from SCM at any location, from the
tag requested. It then builds a clean version of the code and deploys
it to the remote repository.
You can automate this using the appropriate properties, but for any
that are not provided you will be prompted for them.
</description>
</goal>
</goals>
</body>
</document>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="Maven Source Control Management Plug-in">
<title>Maven Source Control Management Plug-in</title>
<body>
<links>
<item href="http://maven.apache.org/" name="Maven">
</item>
</links>
<menu name="Overview">
<item href="/goals.html" name="Goals">
</item>
<item href="/properties.html" name="Properties">
</item>
</menu>
</body>
</project>

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
<title>Maven Source Control Management Plug-in Properties</title>
</properties>
<body>
<section name="Maven Source Control Management Plug-in Settings">
<subsection name="General SCM Settings">
<table>
<tr>
<th>Property</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td>maven.scm.method</td>
<td>Yes</td>
<td>
<p>Default value is
<code>cvs</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.checkout.dir</td>
<td>Yes</td>
<td>
<p>Default value is
<code>${basedir}/checkouts</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.check.tagged</td>
<td>Yes</td>
<td>
<p>When <code>true</code>, you will be asked for confirmation if
you are attempting to release from <code>HEAD</code>.
Default value is <code>true</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.bootstrap.goals</td>
<td>No</td>
<td>
<p>Goals to call on the checked out project.</p>
</td>
</tr>
<tr>
<td>maven.scm.bootstrap.pom.dir</td>
<td>Yes</td>
<td>
<p>Where to find project.xml in the checked out project.</p>
</td>
</tr>
</table>
</subsection>
<subsection name="CVS Settings">
<table>
<tr>
<th>Property</th>
<th>Optional?</th>
<th>Description</th>
</tr>
<tr>
<td>maven.scm.cvs.root</td>
<td>Yes</td>
<td>
<p>Default value is taken from CVSROOT in the environment.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.update.flags</td>
<td>Yes</td>
<td>
<p>Default value is
<code>-Pd</code>. Note that any environment settings
(eg .cvsrc) will also affect this.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.module</td>
<td>No</td>
<td>
<p>The CVS module to checkout</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.sticky.tag</td>
<td>Yes</td>
<td>
<p>Sticky tag to use when checking out or updating. Default is none.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.quiet</td>
<td>Yes</td>
<td>
<p>Default value is
<code>true</code>.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.checkout.flags</td>
<td>Yes</td>
<td>
<p>Default value is
<code>-P</code>. Note that any environment settings
(eg .cvsrc) will also affect this.</p>
</td>
</tr>
<tr>
<td>maven.scm.cvs.rsh</td>
<td>Yes</td>
<td>
<p>Default value is taken from CVS_RSH in the environment.</p>
</td>
</tr>
</table>
</subsection>
</section>
</body>
</document>