You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by da...@apache.org on 2009/01/11 21:37:15 UTC
svn commit: r733515 - in /maven/scm/trunk/maven-scm-plugin/src:
main/java/org/apache/maven/scm/plugin/
test/java/org/apache/maven/scm/plugin/ test/resources/mojos/checkout/
Author: dantran
Date: Sun Jan 11 12:37:15 2009
New Revision: 733515
URL: http://svn.apache.org/viewvc?rev=733515&view=rev
Log:
SCM-437: add option use export in checkout mojo, and therefore bootstrap mojo inherits it as well
Added:
maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutUsingExport.xml
Modified:
maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java
maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java?rev=733515&r1=733514&r2=733515&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java (original)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/BootstrapMojo.java Sun Jan 11 12:37:15 2009
@@ -19,7 +19,11 @@
* under the License.
*/
+import java.io.File;
+
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -27,8 +31,6 @@
import org.codehaus.plexus.util.cli.DefaultConsumer;
import org.codehaus.plexus.util.cli.StreamConsumer;
-import java.io.File;
-
/**
* Pull the project source from the configured scm and execute the configured goals.
*
@@ -74,7 +76,19 @@
if ( this.getCheckoutResult() != null )
{
- runGoals( this.getCheckoutResult().getRelativePathProjectDirectory() );
+
+ ScmResult checkoutResult = this.getCheckoutResult();
+
+ //At the time of useExport feature is requested only SVN and and CVS have export command implemented
+ // we will deal with this as more user using this feature specially clearcase where we need to
+ // add relativePathProjectDirectory support to ExportScmResult
+ String relativePathProjectDirectory = "";
+ if ( checkoutResult instanceof CheckOutScmResult )
+ {
+ relativePathProjectDirectory = ( (CheckOutScmResult) checkoutResult).getRelativePathProjectDirectory();
+ }
+
+ runGoals( relativePathProjectDirectory );
}
}
Modified: maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java?rev=733515&r1=733514&r2=733515&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java (original)
+++ maven/scm/trunk/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java Sun Jan 11 12:37:15 2009
@@ -19,16 +19,17 @@
* under the License.
*/
+import java.io.File;
+import java.io.IOException;
+
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.repository.ScmRepository;
import org.codehaus.plexus.util.FileUtils;
-import java.io.File;
-import java.io.IOException;
-
/**
* Get a fresh copy of the latest source from the configured scm url.
*
@@ -41,6 +42,13 @@
extends AbstractScmMojo
{
/**
+ * Use Export instead of checkout
+ *
+ * @parameter expression="${useExport}" defaultValue="false";
+ */
+ private boolean useExport;
+
+ /**
* The directory to checkout the sources to for the bootstrap and checkout goals.
*
* @parameter expression="${checkoutDirectory}" default-value="${project.build.directory}/checkout"
@@ -71,7 +79,7 @@
/**
* allow extended mojo (ie BootStrap ) to see checkout result
*/
- private CheckOutScmResult checkoutResult;
+ private ScmResult checkoutResult;
/** {@inheritDoc} */
public void execute()
@@ -97,32 +105,27 @@
this.checkoutDirectory = checkoutDirectory;
}
- protected CheckOutScmResult checkout()
+ protected ScmResult checkout()
throws MojoExecutionException
{
try
{
ScmRepository repository = getScmRepository();
- try
- {
- this.getLog().info( "Removing " + getCheckoutDirectory() );
-
- FileUtils.deleteDirectory( getCheckoutDirectory() );
- }
- catch ( IOException e )
+ this.prepareOutputDirectory( getCheckoutDirectory() );
+
+ ScmResult result = null;
+
+ ScmFileSet fileSet = new ScmFileSet( getCheckoutDirectory().getAbsoluteFile() );
+ if ( useExport )
{
- throw new MojoExecutionException( "Cannot remove " + getCheckoutDirectory() );
+ result = getScmManager().export( repository,fileSet, getScmVersion( scmVersionType, scmVersion ) );
}
-
- if ( !getCheckoutDirectory().mkdirs() )
+ else
{
- throw new MojoExecutionException( "Cannot create " + getCheckoutDirectory() );
+ result = getScmManager().checkOut( repository,fileSet , getScmVersion( scmVersionType, scmVersion ) );
}
- CheckOutScmResult result = getScmManager().checkOut( repository, new ScmFileSet(
- getCheckoutDirectory().getAbsoluteFile() ), getScmVersion( scmVersionType, scmVersion ) );
-
checkResult( result );
return result;
@@ -133,7 +136,27 @@
}
}
- protected CheckOutScmResult getCheckoutResult()
+ private void prepareOutputDirectory( File ouputDirectory )
+ throws MojoExecutionException
+ {
+ try
+ {
+ this.getLog().info( "Removing " + ouputDirectory );
+
+ FileUtils.deleteDirectory( getCheckoutDirectory() );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot remove " + ouputDirectory );
+ }
+
+ if ( !getCheckoutDirectory().mkdirs() )
+ {
+ throw new MojoExecutionException( "Cannot create " + ouputDirectory );
+ }
+ }
+
+ protected ScmResult getCheckoutResult()
{
return checkoutResult;
}
Modified: maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java?rev=733515&r1=733514&r2=733515&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java (original)
+++ maven/scm/trunk/maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/CheckoutMojoTest.java Sun Jan 11 12:37:15 2009
@@ -110,4 +110,18 @@
}
}
+ public void testUseExport()
+ throws Exception
+ {
+ checkoutDir.mkdirs();
+
+ CheckoutMojo mojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile(
+ "src/test/resources/mojos/checkout/checkoutUsingExport.xml" ) );
+
+ mojo.setCheckoutDirectory( checkoutDir );
+
+ mojo.execute();
+
+ assertTrue( checkoutDir.listFiles().length > 0 );
+ assertFalse( new File( checkoutDir, ".svn" ).exists() ); }
}
Added: maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutUsingExport.xml
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutUsingExport.xml?rev=733515&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutUsingExport.xml (added)
+++ maven/scm/trunk/maven-scm-plugin/src/test/resources/mojos/checkout/checkoutUsingExport.xml Sun Jan 11 12:37:15 2009
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.
+ -->
+
+<project>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-scm-plugin</artifactId>
+ <configuration>
+ <settings implementation="org.apache.maven.settings.Settings"/>
+ <checkoutDirectory>target/checkout</checkoutDirectory>
+ <connectionType>connection</connectionType>
+ <useExport>true</useExport>
+ <connectionUrl>scm:svn:file:///${basedir}/target/repository/trunk</connectionUrl>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file