Permalink
Browse files

[maven-scm] copy for tag maven-release-1

  • Loading branch information...
1 parent 81dab07 commit b790f5d7cff3bdcc19d94433084019795cb4f003 Jesse McConnell committed Apr 13, 2007
@@ -79,52 +79,57 @@
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-bazaar</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-clearcase</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-cvsexe</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-cvsjava</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-hg</artifactId>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-perforce</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-starteam</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-svnexe</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-synergy</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
</dependency>
<dependency>
<groupId>jdom</groupId>
@@ -164,7 +169,7 @@
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-test</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0-rc1</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -21,6 +21,7 @@
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.provider.ScmProvider;
@@ -244,7 +245,7 @@ public void rollback( ReleaseDescriptor releaseDescriptor, Settings settings, Li
releaseDescriptor = loadReleaseDescriptor( releaseDescriptor, null );
- for( Iterator phases = rollbackPhases.iterator(); phases.hasNext(); )
+ for ( Iterator phases = rollbackPhases.iterator(); phases.hasNext(); )
{
String name = (String) phases.next();
@@ -395,8 +396,8 @@ private void perform( ReleaseDescriptor releaseDescriptor, Settings settings, Li
CheckOutScmResult scmResult;
try
{
- scmResult =
- provider.checkOut( repository, new ScmFileSet( checkoutDirectory ), config.getScmReleaseLabel() );
+ scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
+ new ScmTag( config.getScmReleaseLabel() ) );
}
catch ( ScmException e )
{
@@ -430,7 +431,8 @@ private void perform( ReleaseDescriptor releaseDescriptor, Settings settings, Li
try
{
- mavenExecutor.executeGoals( checkoutDirectory, goals, config.isInteractive(), additionalArguments,
+ File workingDirectory = determineWorkingDirectory(checkoutDirectory, scmResult.getRelativePathProjectDirectory());
+ mavenExecutor.executeGoals( workingDirectory, goals, config.isInteractive(), additionalArguments,
config.getPomFileName(), result );
}
catch ( MavenExecutorException e )
@@ -449,7 +451,32 @@ private void perform( ReleaseDescriptor releaseDescriptor, Settings settings, Li
updateListener( listener, "perform", GOAL_END );
}
- private ReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptor releaseDescriptor, ReleaseManagerListener listener )
+ /**
+ * Determines the path of the working directory. By default, this is the
+ * checkout directory. For some SCMs, the project root directory is not the
+ * checkout directory itself, but a SCM-specific subdirectory.
+ *
+ * @param checkoutDirectory
+ * The checkout directory as java.io.File
+ * @param relativePathProjectDirectory
+ * The relative path of the project directory within the checkout
+ * directory or ""
+ * @return The working directory
+ */
+ protected File determineWorkingDirectory( File checkoutDirectory, String relativePathProjectDirectory)
+ {
+ if ( StringUtils.isNotEmpty( relativePathProjectDirectory ) )
+ {
+ return new File( checkoutDirectory, relativePathProjectDirectory );
+ }
+ else
+ {
+ return checkoutDirectory;
+ }
+ }
+
+ private ReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptor releaseDescriptor,
+ ReleaseManagerListener listener )
throws ReleaseExecutionException
{
try
@@ -94,7 +94,8 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, Settings sett
try
{
ScmFileSet fileSet = new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ), files );
- result = provider.checkIn( repository, fileSet, null, createMessage( releaseDescriptor ) );
+ //TODO: Use ScmVersion instead of String for the branch/tag/revision parameter
+ result = provider.checkIn( repository, fileSet, (String) null, createMessage( releaseDescriptor ) );
}
catch ( ScmException e )
{
@@ -82,7 +82,8 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, Settings sett
{
// TODO: want includes/excludes?
ScmFileSet fileSet = new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ) );
- result = provider.tag( repository, fileSet, releaseDescriptor.getScmReleaseLabel() );
+ String tagName = releaseDescriptor.getScmReleaseLabel();
+ result = provider.tag( repository, fileSet, tagName, "[maven-release-manager] copy for tag " + tagName );
}
catch ( ScmException e )
{
@@ -0,0 +1,46 @@
+package org.apache.maven.shared.release.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * ClearCase tag translator.
+ *
+ * @author <a href="mailto:arne@degenring.com">Arne Degenring</a>
+ */
+public class ClearCaseScmTranslator
+ implements ScmTranslator
+{
+ public String translateTagUrl( String url, String tag, String tagBase )
+ {
+ return url;
+ }
+
+ public String resolveTag( String tag )
+ {
+ if ( !"HEAD".equals( tag ) )
+ {
+ return tag;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
@@ -19,6 +19,7 @@
* under the License.
*/
+import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.provider.svn.SvnTagBranchUtils;
/**
@@ -31,7 +32,7 @@
{
public String translateTagUrl( String url, String tag, String tagBase )
{
- return SvnTagBranchUtils.resolveUrl( url, tagBase, SvnTagBranchUtils.SVN_TAGS, tag );
+ return SvnTagBranchUtils.resolveUrl( url, tagBase, SvnTagBranchUtils.SVN_TAGS, new ScmTag( tag ) );
}
public String resolveTag( String tag )
@@ -266,6 +266,11 @@
<implementation>org.apache.maven.shared.release.scm.CvsScmTranslator</implementation>
</component>
<component>
+ <role>org.apache.maven.shared.release.scm.ScmTranslator</role>
+ <role-hint>clearcase</role-hint>
+ <implementation>org.apache.maven.shared.release.scm.ClearCaseScmTranslator</implementation>
+ </component>
+ <component>
<role>org.apache.maven.shared.release.exec.MavenExecutor</role>
<implementation>org.apache.maven.shared.release.exec.ForkedMavenExecutor</implementation>
<requirements>
@@ -21,6 +21,7 @@
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
@@ -42,10 +43,12 @@
import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
import org.jmock.Mock;
import org.jmock.core.Constraint;
import org.jmock.core.constraint.IsAnything;
import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.constraint.IsInstanceOf;
import org.jmock.core.constraint.IsNull;
import org.jmock.core.constraint.IsSame;
import org.jmock.core.matcher.InvokeOnceMatcher;
@@ -400,7 +403,7 @@ public void testReleasePerform()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -429,7 +432,7 @@ public void testReleasePerformNoReleaseProfile()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -460,7 +463,7 @@ public void testReleasePerformWithArguments()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -490,7 +493,7 @@ public void testReleasePerformWithArgumentsNoReleaseProfile()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -519,7 +522,7 @@ public void testReleasePerformWithReleasePropertiesCompleted()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -741,7 +744,7 @@ public void testReleasePerformExecutionException()
Mock scmProviderMock = new Mock( ScmProvider.class );
constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
- new IsNull()};
+ new IsInstanceOf( ScmTag.class )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
new ReturnStub( new CheckOutScmResult( "...", Collections.EMPTY_LIST ) ) );
@@ -760,4 +763,28 @@ public void testReleasePerformExecutionException()
}
}
+ public void testDetermineWorkingDirectory()
+ throws Exception
+ {
+ DefaultReleaseManager defaultReleaseManager = new DefaultReleaseManager();
+
+ File checkoutDir = getTestFile( "target/checkout" );
+ FileUtils.forceDelete( checkoutDir );
+ checkoutDir.mkdirs();
+
+ File projectDir = getTestFile( "target/checkout/my/project" );
+ projectDir.mkdirs();
+
+ // only checkout dir
+ assertEquals( checkoutDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir, "" ) );
+ assertEquals( checkoutDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir, null ) );
+
+ // checkout dir and relative path project dir
+ assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir, "my/project" ) );
+ assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir, "my/project/" ) );
+ assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir, "my"
+ + File.separator + "project" ) );
+
+ FileUtils.forceDelete( checkoutDir);
+ }
}
@@ -78,7 +78,8 @@ public void testTag()
Mock scmProviderMock = new Mock( ScmProvider.class );
Constraint[] arguments =
- new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual( "release-label" )};
+ new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual( "release-label" ),
+ new IsEqual( "[maven-release-manager] copy for tag release-label" )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments ).will(
new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile() ) ) ) );
@@ -104,7 +105,8 @@ public void testCommitMultiModule()
Mock scmProviderMock = new Mock( ScmProvider.class );
Constraint[] arguments =
- new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual( "release-label" )};
+ new Constraint[]{new IsAnything(), new IsScmFileSetEquals( fileSet ), new IsEqual( "release-label" ),
+ new IsEqual( "[maven-release-manager] copy for tag release-label" )};
scmProviderMock.expects( new InvokeOnceMatcher() ).method( "tag" ).with( arguments ).will(
new ReturnStub( new TagScmResult( "...", Collections.singletonList( rootProject.getFile() ) ) ) );
Oops, something went wrong.

0 comments on commit b790f5d

Please sign in to comment.