You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2004/12/23 22:46:56 UTC
svn commit: r123231 - in maven/maven-1/plugins/branches/scm-1.5-branch: . src/main/org/apache/maven/plugins/scm
Author: brett
Date: Thu Dec 23 13:46:55 2004
New Revision: 123231
URL: http://svn.apache.org/viewcvs?view=rev&rev=123231
Log:
implement majority of scm:prepare-release
Added:
maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmCheckinBean.java
maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmPatternBean.java
maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmStatusBean.java
Modified:
maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly
maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java
Modified: maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly?view=diff&rev=123231&p1=maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly&r1=123230&p2=maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly&r2=123231
==============================================================================
--- maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly (original)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly Thu Dec 23 13:46:55 2004
@@ -24,9 +24,7 @@
xmlns:r="release:transform"
xmlns:c="changes:transform"
xmlns:define="jelly:define"
- xmlns:log="jelly:log"
xmlns:ant="jelly:ant"
- xmlns:doc="doc"
xmlns:scm="scm"
xmlns:util="jelly:util"
xmlns:maven="jelly:maven">
@@ -47,6 +45,16 @@
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:taglib>
<goal name="scm:find-connection">
@@ -168,6 +176,55 @@
<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}" excludes="project.xml,xdocs/changes.xml" />
+
+ <j:if test="${scmStatusBean.hasModifications()}">
+ <!-- TODO: list modifications? -->
+ <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:if>
+
+ <i:ask
+ question="What is the new tag name?"
+ answer="tag_name"
+ default="${maven.scm.tag}"
+ />
+ <i:ask
+ question="What is the new version?"
+ answer="version_name"
+ default="${tag_name}"
+ />
+
+ <!-- TODO: verify that the name is valid for a tag -->
+
+ <!-- Update project.xml -->
+ <r: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>
+
+ <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 var="scmCheckinBean" url="${scmConnection}" workingDirectory="${basedir}" includes="project.xml,xdocs/changes.xml" message="[maven-scm-plugin] prepare release ${version_name}" />
+
+ <ant:echo>Tagging source tree</ant:echo>
+ <scm:tag var="scmTagBean" url="${scmConnection}" workingDirectory="${basedir}" tag="${tag_name}" />
+ </goal>
+
<!--
DEPRECATED METHODS
-->
@@ -228,7 +285,7 @@
</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>
+ <ant:echo>Using SCM method: ${scmMethod}</ant:echo>
<j:if test="${scmMethod == 'cvs'}">
<j:choose>
<j:when test="${tokens[2] == 'local'}">
@@ -240,15 +297,15 @@
<j:set var="maven.scm.cvs.module" value="${tokens[5]}"/>
</j:otherwise>
</j:choose>
- <log:info>Using CVSROOT: ${maven.scm.cvs.root}</log:info>
- <log:info>Using module: ${maven.scm.cvs.module}</log:info>
+ <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="maven.scm.svn.module" value="${tokens[4]}"/>
- <log:info>Using SVN repository: ${maven.scm.svn.root}</log:info>
- <log:info>Using module: ${maven.scm.svn.module}</log:info>
+ <ant:echo>Using SVN repository: ${maven.scm.svn.root}</ant:echo>
+ <ant:echo>Using module: ${maven.scm.svn.module}</ant:echo>
</j:if>
</j:if>
</goal>
@@ -300,7 +357,7 @@
<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>
+ <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"
@@ -331,103 +388,13 @@
</j:choose>
</goal>
- <!-- TODO: the below may be need to be ported or removed -->
-
- <!--==================================================================-->
- <!-- Prepare Release -->
- <!--==================================================================-->
- <goal name="scm:prepare-release"
- prereqs="scm:validate"
- description="Prepare for a release in SCM">
- <j:choose>
- <j:when test="${scmMethod == 'cvs'}">
- <attainGoal name="scm:cvs-prepare-release"/>
- </j:when>
- <j:otherwise>
- <ant:fail>Unsupported scm type: ${scmMethod}</ant:fail>
- </j:otherwise>
- </j:choose>
- </goal>
-
<goal name="scm:cvs-prepare-release">
- <log:info>Verifying no modifications are present</log:info>
- <j:set var="changesFilename" value="${maven.docs.src}/changes.xml" />
- <util:file var="file" name="${changesFilename}"/>
- <j:set var="changesExists" value="${file.exists()}" />
- <!-- Need to move POM out of the way as mods there are allowed -->
- <ant:move file="project.xml" tofile="project.xml.SCM.temp" />
- <j:set var="documents" value="project.xml" />
- <j:if test="${changesExists}">
- <maven:makeRelativePath basedir="${basedir}" path="${changesFilename}" var="changesFilename" />
- <util:replace var="changesFilename" value="${changesFilename}" oldChar="\\" newChar="/" />
- <j:set var="documents" value="${documents} ${changesFilename}" />
- <ant:move file="${changesFilename}" tofile="${changesFilename}.SCM.temp" />
- </j:if>
- <j:catch var="exception">
- <ant:cvs command="update ${documents}"
- 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"
- />
- </j:catch>
- <ant:move file="project.xml.SCM.temp" tofile="project.xml" />
- <j:if test="${changesExists}">
- <ant:move file="${changesFilename}.SCM.temp" tofile="${changesFilename}" />
- </j:if>
- <j:if test="${exception != null}">
- <ant:fail>${exception}</ant:fail>
- </j:if>
- <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 -F ${tag_name} project.xml"
- noexec="true"
- quiet="${maven.scm.cvs.quiet}"
- cvsRsh="${maven.scm.cvs.rsh}"
- cvsRoot="${maven.scm.cvs.root}"
- failonerror="true"
- />
-
- <r:release-version version="${version_name}" tag="${tag_name}" />
- <j:if test="${changesExists}">
- <c:release-version version="${version_name}" />
- </j:if>
- <log:info>Committing new documents: ${documents}</log:info>
- <ant:cvs command="commit -m '[maven-scm-plugin] prepare release ${version_name}' ${documents}"
- 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 -F ${tag_name}"
- quiet="${maven.scm.cvs.quiet}"
- cvsRsh="${maven.scm.cvs.rsh}"
- cvsRoot="${maven.scm.cvs.root}"
- failonerror="true"
- />
+ <ant:echo>DEPRECATED: please use scm:prepare-release</ant:echo>
+ <attainGoal name="scm:prepare-release"/>
</goal>
- <!--==================================================================-->
- <!-- Patch - CVS -->
- <!--==================================================================-->
+ <!-- TODO: the below needs to be ported -->
+
<goal name="scm:cvs-create-patch">
<ant:delete dir="${maven.scm.cvs.patch.dir}"/>
<ant:mkdir dir="${maven.scm.cvs.patch.dir}"/>
Modified: maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java?view=diff&rev=123231&p1=maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java&r1=123230&p2=maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java&r2=123231
==============================================================================
--- maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java (original)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmBean.java Thu Dec 23 13:46:55 2004
@@ -21,11 +21,8 @@
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.command.tag.TagScmResult;
import org.apache.maven.scm.command.update.UpdateScmResult;
-import org.apache.maven.scm.manager.DefaultScmManager;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.DefaultPlexusContainer;
import org.codehaus.plexus.embed.Embedder;
import org.codehaus.plexus.util.FileUtils;
@@ -47,7 +44,7 @@
// note - this should not have a setter
private File checkoutDirectory;
- private Embedder getEmbedder() throws Exception
+ protected Embedder getEmbedder() throws Exception
{
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
@@ -88,7 +85,7 @@
checkResult( result );
}
- private void checkResult( ScmResult result ) throws Exception
+ protected void checkResult( ScmResult result ) throws Exception
{
if ( !result.isSuccess() )
{
Added: maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmCheckinBean.java
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmCheckinBean.java?view=auto&rev=123231
==============================================================================
--- (empty file)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmCheckinBean.java Thu Dec 23 13:46:55 2004
@@ -0,0 +1,62 @@
+package org.apache.maven.plugins.scm;
+
+/* ====================================================================
+ * 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.
+ * ====================================================================
+ */
+
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.embed.Embedder;
+
+import java.io.File;
+
+/**
+ * A bean for using the Maven SCM API because wrangling objects in Jelly is no fun.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmCheckinBean extends ScmPatternBean
+{
+ private String message;
+
+ public void checkin() throws Exception
+ {
+ // TODO: can this be shared more?
+ Embedder embedder = getEmbedder();
+ ScmManager scmManager = (ScmManager) embedder.lookup( ScmManager.ROLE );
+
+ ScmRepository repository = scmManager.makeScmRepository( getUrl() );
+
+ CheckInScmResult result = scmManager.checkIn( repository, new File( getWorkingDirectory() ), getTag(), message );
+ // TODO: should be this:
+ //CheckInScmResult result = scmManager.checkIn( repository, new File( getWorkingDirectory() ), getTag(), message, getIncludes(), getExcludes() );
+
+ checkResult( result );
+ }
+
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+}
+
Added: maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmPatternBean.java
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmPatternBean.java?view=auto&rev=123231
==============================================================================
--- (empty file)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmPatternBean.java Thu Dec 23 13:46:55 2004
@@ -0,0 +1,51 @@
+package org.apache.maven.plugins.scm;
+
+/* ====================================================================
+ * 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.
+ * ====================================================================
+ */
+
+/**
+ * A bean for using the Maven SCM API because wrangling objects in Jelly is no fun.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmPatternBean extends ScmBean
+{
+ private String includes;
+
+ private String excludes;
+
+ public void setIncludes( String includes )
+ {
+ this.includes = includes;
+ }
+
+ public String getIncludes()
+ {
+ return includes;
+ }
+
+ public void setExcludes( String excludes )
+ {
+ this.excludes = excludes;
+ }
+
+ public String getExcludes()
+ {
+ return excludes;
+ }
+}
+
Added: maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmStatusBean.java
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmStatusBean.java?view=auto&rev=123231
==============================================================================
--- (empty file)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmStatusBean.java Thu Dec 23 13:46:55 2004
@@ -0,0 +1,48 @@
+package org.apache.maven.plugins.scm;
+
+/* ====================================================================
+ * 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.
+ * ====================================================================
+ */
+
+//import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.embed.Embedder;
+
+/**
+ * A bean for using the Maven SCM API because wrangling objects in Jelly is no fun.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmStatusBean extends ScmPatternBean
+{
+ public void status() throws Exception
+ {
+ // TODO: can this be shared more?
+ Embedder embedder = getEmbedder();
+ ScmManager scmManager = (ScmManager) embedder.lookup( ScmManager.ROLE );
+
+ ScmRepository repository = scmManager.makeScmRepository( getUrl() );
+
+/* TODO
+ // TODO: svn tag base, unless is HEAD, BASE, COMMITTED, PREV, rev#, {DATE}
+ UpdateScmResult result = scmManager.update( repository, new File( workingDirectory ), tag );
+
+ checkResult( result );
+*/
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org