You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2014/01/28 22:53:34 UTC
svn commit: r1562248 - in /maven/plugins/trunk/maven-scm-publish-plugin:
pom.xml
src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
Author: rfscholte
Date: Tue Jan 28 21:53:33 2014
New Revision: 1562248
URL: http://svn.apache.org/r1562248
Log:
[MSCMPUB-10] Pick up SCM credentials from settings.xml server section
Modified:
maven/plugins/trunk/maven-scm-publish-plugin/pom.xml
maven/plugins/trunk/maven-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
Modified: maven/plugins/trunk/maven-scm-publish-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-scm-publish-plugin/pom.xml?rev=1562248&r1=1562247&r2=1562248&view=diff
==============================================================================
--- maven/plugins/trunk/maven-scm-publish-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-scm-publish-plugin/pom.xml Tue Jan 28 21:53:33 2014
@@ -54,7 +54,7 @@ under the License.
<properties>
<scmVersion>1.9</scmVersion>
- <mavenVersion>2.2.1</mavenVersion>
+ <mavenVersion>3.0</mavenVersion>
<pluginTools>3.2</pluginTools>
<maven.site.path>plugins-archives/${project.artifactId}-LATEST</maven.site.path>
@@ -62,6 +62,10 @@ under the License.
<maven-scm-provider-svnjava-version>2.0.6</maven-scm-provider-svnjava-version>
<svnkit-version>1.7.11</svnkit-version>
</properties>
+
+ <prerequisites>
+ <maven>${mavenVersion}</maven>
+ </prerequisites>
<dependencies>
<dependency>
@@ -81,11 +85,6 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
<version>${mavenVersion}</version>
</dependency>
Modified: maven/plugins/trunk/maven-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java?rev=1562248&r1=1562247&r2=1562248&view=diff
==============================================================================
--- maven/plugins/trunk/maven-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java (original)
+++ maven/plugins/trunk/maven-scm-publish-plugin/src/main/java/org/apache/maven/plugins/scmpublish/AbstractScmPublishMojo.java Tue Jan 28 21:53:33 2014
@@ -19,6 +19,17 @@ package org.apache.maven.plugins.scmpubl
* under the License.
*/
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
@@ -38,25 +49,20 @@ import org.apache.maven.scm.command.chec
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.ScmUrlUtils;
import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
+import org.apache.maven.settings.crypto.SettingsDecrypter;
+import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
+import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.apache.maven.shared.release.config.ReleaseDescriptor;
import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
/**
* Base class for the scm-publish mojos.
*/
@@ -141,6 +147,12 @@ public abstract class AbstractScmPublish
*/
@Component
protected ScmRepositoryConfigurator scmRepositoryConfigurator;
+
+ /**
+ * The serverId specified in the settings.xml, which should be used for the authentication.
+ */
+ @Parameter
+ private String serverId;
/**
* The SCM username to use.
@@ -184,6 +196,10 @@ public abstract class AbstractScmPublish
*/
@Component
protected Settings settings;
+
+ @Component
+ private SettingsDecrypter settingsDecrypter;
+
/**
* Collections of paths not to delete when checking content to delete.
@@ -266,21 +282,50 @@ public abstract class AbstractScmPublish
// in the release phase we have to change the checkout URL
// to do a local checkout instead of going over the network.
- // the first step is a bit tricky, we need to know which provider! like e.g. "scm:jgit:http://"
- // the offset of 4 is because 'scm:' has 4 characters...
- String providerPart = pubScmUrl.substring( 0, pubScmUrl.indexOf( ':', 4 ) );
+ String provider = ScmUrlUtils.getProvider( pubScmUrl );
+ String delimiter = ScmUrlUtils.getDelimiter( pubScmUrl );
+
+ String providerPart = "scm:" + provider + delimiter;
// X TODO: also check the information from releaseDescriptor.getScmRelativePathProjectDirectory()
// X TODO: in case our toplevel git directory has no pom.
// X TODO: fix pathname once I understand this.
- scmUrl = providerPart + ":file://" + "target/localCheckout";
+ scmUrl = providerPart + "file://" + "target/localCheckout";
logInfo( "Performing a LOCAL checkout from " + scmUrl );
}
ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
releaseDescriptor.setInteractive( settings.isInteractiveMode() );
- //TODO use from settings with decrypt stuff
+ if ( username == null || password == null )
+ {
+ for ( Server server : settings.getServers() )
+ {
+ if ( server.getId().equals( serverId ) )
+ {
+ SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest( server );
+
+ SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt( decryptionRequest );
+
+ if ( !decryptionResult.getProblems().isEmpty() )
+ {
+ // todo throw exception?
+ }
+
+ if ( username == null )
+ {
+ username = decryptionResult.getServer().getUsername();
+ }
+
+ if ( password == null )
+ {
+ password = decryptionResult.getServer().getPassword();
+ }
+
+ break;
+ }
+ }
+ }
releaseDescriptor.setScmPassword( password );
releaseDescriptor.setScmUsername( username );