Repository: maven-scm Updated Branches: refs/heads/master cc0b8fdb4 -> 82b8f4bd3
[SCM-757] work around for project.basedir is not valid under maven 3 when run without a project ( ie mvn scm:checkout, scm:bootstrap, and scm:export) Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/82b8f4bd Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/82b8f4bd Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/82b8f4bd Branch: refs/heads/master Commit: 82b8f4bd3e3f61d2e98209e758c43afd41b987d8 Parents: cc0b8fd Author: dantran <dant...@gmail.com> Authored: Wed Jun 25 00:22:22 2014 -0700 Committer: dantran <dant...@gmail.com> Committed: Wed Jun 25 00:22:22 2014 -0700 ---------------------------------------------------------------------- .../maven/scm/plugin/AbstractScmMojo.java | 15 ++++++++---- .../apache/maven/scm/plugin/CheckoutMojo.java | 21 +++++++++------- .../org/apache/maven/scm/plugin/ExportMojo.java | 25 ++++++++++++-------- 3 files changed, 38 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-scm/blob/82b8f4bd/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java ---------------------------------------------------------------------- diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java index 8c76df4..de2d18c 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/AbstractScmMojo.java @@ -158,10 +158,10 @@ public abstract class AbstractScmMojo */ @Parameter private Map<String,String> providerImplementations; - + /** * Should distributed changes be pushed to the central repository? - * For many distributed SCMs like Git, a change like a commit + * For many distributed SCMs like Git, a change like a commit * is only stored in your local copy of the repository. Pushing * the change allows your to more easily share it with other users. * @@ -244,6 +244,11 @@ public abstract class AbstractScmMojo return workingDirectory; } + public File getBasedir() + { + return this.basedir; + } + public void setWorkingDirectory( File workingDirectory ) { this.workingDirectory = workingDirectory; @@ -277,7 +282,7 @@ public abstract class AbstractScmMojo repository = getScmManager().makeScmRepository( getConnectionUrl() ); ScmProviderRepository providerRepo = repository.getProviderRepository(); - + providerRepo.setPushChanges( pushChanges ); if ( !StringUtils.isEmpty( username ) ) @@ -470,7 +475,7 @@ public abstract class AbstractScmMojo throw new MojoExecutionException( "Unknown '" + versionType + "' version type." ); } - + protected void handleExcludesIncludesAfterCheckoutAndExport( File checkoutDirectory ) throws MojoExecutionException { @@ -495,7 +500,7 @@ public abstract class AbstractScmMojo excludes.add( tokens[i] ); } } - + if ( includes.isEmpty() && excludes.isEmpty() ) { return; http://git-wip-us.apache.org/repos/asf/maven-scm/blob/82b8f4bd/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java ---------------------------------------------------------------------- diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java index 29156d6..df6b4fb 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/CheckoutMojo.java @@ -45,7 +45,7 @@ public class CheckoutMojo */ @Parameter( property = "useExport", defaultValue = "false" ) private boolean useExport; - + /** * The directory to checkout the sources to for the bootstrap and checkout goals. */ @@ -91,6 +91,11 @@ public class CheckoutMojo protected File getCheckoutDirectory() { + if ( this.checkoutDirectory.getPath().contains( "${project.basedir}" )) + { + //project.basedir is not set under maven 3.x when run without a project + this.checkoutDirectory = new File( this.getBasedir(), "target/checkout"); + } return this.checkoutDirectory; } @@ -107,9 +112,9 @@ public class CheckoutMojo ScmRepository repository = getScmRepository(); this.prepareOutputDirectory( getCheckoutDirectory() ); - + ScmResult result = null; - + ScmFileSet fileSet = new ScmFileSet( getCheckoutDirectory().getAbsoluteFile() ); if ( useExport ) { @@ -121,8 +126,8 @@ public class CheckoutMojo } checkResult( result ); - - + + handleExcludesIncludesAfterCheckoutAndExport( this.checkoutDirectory ); return result; @@ -146,17 +151,17 @@ public class CheckoutMojo { throw new MojoExecutionException( "Cannot remove " + ouputDirectory ); } - + if ( !getCheckoutDirectory().mkdirs() ) { throw new MojoExecutionException( "Cannot create " + ouputDirectory ); } } - + protected ScmResult getCheckoutResult() { return checkoutResult; } - + } http://git-wip-us.apache.org/repos/asf/maven-scm/blob/82b8f4bd/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java ---------------------------------------------------------------------- diff --git a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java index d194448..96b1ff8 100644 --- a/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java +++ b/maven-scm-plugin/src/main/java/org/apache/maven/scm/plugin/ExportMojo.java @@ -6,9 +6,9 @@ package org.apache.maven.scm.plugin; * 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 @@ -29,7 +29,7 @@ import org.codehaus.plexus.util.FileUtils; /** * Get a fresh exported copy of the latest source from the configured scm url. - * + * * @author <a href="mailto:eveni...@apache.org">Emmanuel Venisse</a> */ @Mojo( name = "export", requiresProject = false ) @@ -53,13 +53,13 @@ public class ExportMojo */ @Parameter( property = "exportDirectory", defaultValue = "${project.build.directory}/export", required = true ) private File exportDirectory; - + /** * Skip export if exportDirectory exists. */ @Parameter( property = "skipExportIfExists", defaultValue = "false" ) private boolean skipExportIfExists = false; - + /** {@inheritDoc} */ public void execute() @@ -71,7 +71,7 @@ public class ExportMojo { return; } - + export(); } @@ -88,6 +88,11 @@ public class ExportMojo protected void export() throws MojoExecutionException { + if ( this.exportDirectory.getPath().contains( "${project.basedir}" )) + { + //project.basedir is not set under maven 3.x when run without a project + this.exportDirectory = new File( this.getBasedir(), "target/export"); + } try { ScmRepository repository = getScmRepository(); @@ -109,15 +114,15 @@ public class ExportMojo if ( !this.exportDirectory.mkdirs() ) { throw new MojoExecutionException( "Cannot create " + this.exportDirectory ); - } - + } + ExportScmResult result = getScmManager().export( repository, new ScmFileSet( this.exportDirectory.getAbsoluteFile() ), getScmVersion( scmVersionType, scmVersion ) ); checkResult( result ); - - handleExcludesIncludesAfterCheckoutAndExport( this.exportDirectory ); + + handleExcludesIncludesAfterCheckoutAndExport( this.exportDirectory ); } catch ( ScmException e ) {