maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r382452 - in /maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release: AbstractReleaseMojo.java helpers/ScmHelper.java
Date Thu, 02 Mar 2006 17:19:02 GMT
Author: evenisse
Date: Thu Mar  2 09:19:02 2006
New Revision: 382452

URL: http://svn.apache.org/viewcvs?rev=382452&view=rev
Log:
Load correctly parameters from settings

Modified:
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
    maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java?rev=382452&r1=382451&r2=382452&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractReleaseMojo.java
Thu Mar  2 09:19:02 2006
@@ -21,7 +21,7 @@
 import org.apache.maven.plugins.release.helpers.ReleaseProgressTracker;
 import org.apache.maven.plugins.release.helpers.ScmHelper;
 import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.apache.maven.settings.Server;
@@ -45,7 +45,7 @@
      * @required
      * @readonly
      */
-     protected File basedir;    
+    protected File basedir;
 
     /**
      * @component
@@ -104,7 +104,7 @@
 
         scmHelper.setWorkingDirectory( directory );
 
-        loadStarteamUsernamePassword( scmHelper );
+        loadUserInfos( scmHelper );
 
         return scmHelper;
     }
@@ -120,7 +120,7 @@
      * @param scmHelper
      * @throws MojoExecutionException
      */
-    private void loadStarteamUsernamePassword( ScmHelper scmHelper )
+    private void loadUserInfos( ScmHelper scmHelper )
         throws MojoExecutionException
     {
         if ( scmHelper.getUsername() == null || scmHelper.getPassword() == null )
@@ -151,38 +151,57 @@
                 throw new MojoExecutionException( "Can't load the scm provider.", e );
             }
 
-            if ( repository.getProvider().equals( "starteam" ) )
+            if ( repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost
)
             {
-                StarteamScmProviderRepository starteamRepo = (StarteamScmProviderRepository)
repository.getProviderRepository();
+                loadInfosFromSettings( (ScmProviderRepositoryWithHost) repository.getProviderRepository(),
scmHelper );
+            }
+        }
+    }
 
-                String starteamAddress = starteamRepo.getHost();
+    /**
+     * Load username password from settings if user has not set them in JVM properties
+     *
+     * @param repo
+     */
+    private void loadInfosFromSettings( ScmProviderRepositoryWithHost repo, ScmHelper scmHelper
)
+    {
+        if ( scmHelper.getUsername() == null || scmHelper.getPassword() == null )
+        {
+            String host = repo.getHost();
 
-                int starteamPort = starteamRepo.getPort();
+            int port = repo.getPort();
 
-                if ( starteamPort != 0 )
+            if ( port > 0 )
+            {
+                host += ":" + port;
+            }
+
+            Server server = this.settings.getServer( host );
+
+            if ( server != null )
+            {
+                if ( scmHelper.getUsername() == null )
+                {
+                    scmHelper.setUsername( this.settings.getServer( host ).getUsername()
);
+                }
+
+                if ( scmHelper.getPassword() == null )
                 {
-                    starteamAddress += ":" + starteamPort;
+                    scmHelper.setPassword( this.settings.getServer( host ).getPassword()
);
                 }
 
-                Server server = this.settings.getServer( starteamAddress );
+                if ( scmHelper.getPrivateKey() == null )
+                {
+                    scmHelper.setPrivateKey( this.settings.getServer( host ).getPrivateKey()
);
+                }
 
-                if ( server != null )
+                if ( scmHelper.getPassphrase() == null )
                 {
-                    if ( scmHelper.getUsername() == null )
-                    {
-                        scmHelper.setUsername( server.getUsername() );
-                    }
-
-                    if ( scmHelper.getPassword() == null )
-                    {
-                        scmHelper.setPassword( server.getPassword() );
-                    }
+                    scmHelper.setPassphrase( this.settings.getServer( host ).getPassphrase()
);
                 }
             }
         }
-
     }
-
     // ----------------------------------------------------------------------
     // Utility methods
     // ----------------------------------------------------------------------

Modified: maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java?rev=382452&r1=382451&r2=382452&view=diff
==============================================================================
--- maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
(original)
+++ maven/plugins/trunk/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/helpers/ScmHelper.java
Thu Mar  2 09:19:02 2006
@@ -30,6 +30,7 @@
 import org.apache.maven.scm.command.update.UpdateScmResult;
 import org.apache.maven.scm.manager.ScmManager;
 import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.util.FileUtils;
@@ -52,6 +53,10 @@
 
     private String password;
 
+    private String privateKey;
+
+    private String passphrase;
+
     private String url;
 
     private String tag;
@@ -96,6 +101,19 @@
                 scmRepo.setPassword( password );
             }
 
+            if ( scmRepo instanceof ScmProviderRepositoryWithHost )
+            {
+                if ( !StringUtils.isEmpty( privateKey ) )
+                {
+                    ( (ScmProviderRepositoryWithHost) scmRepo ).setPrivateKey( privateKey
);
+                }
+
+                if ( !StringUtils.isEmpty( passphrase ) )
+                {
+                    ( (ScmProviderRepositoryWithHost) scmRepo ).setPassphrase( passphrase
);
+                }
+            }
+
             if ( repository.getProvider().equals( "svn" ) )
             {
                 SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository();
@@ -221,8 +239,8 @@
 
         ScmFileSet fs = new ScmFileSet( new File( workingDirectory ), new File( file ) );
 
-        RemoveScmResult result = getScmManager().getProviderByRepository( repository ).remove(
repository, fs,
-                                                                                        
      message );
+        RemoveScmResult result =
+            getScmManager().getProviderByRepository( repository ).remove( repository, fs,
message );
 
         checkResult( result );
     }
@@ -230,7 +248,7 @@
     public void checkin( List pomFiles, String message )
         throws ScmException
     {
-        File[] files = (File[])pomFiles.toArray( new File[pomFiles.size()] );
+        File[] files = (File[]) pomFiles.toArray( new File[pomFiles.size()] );
 
         ScmRepository repository = getScmRepository();
 
@@ -345,7 +363,27 @@
         this.password = password;
     }
 
-    public boolean requiresEditMode() 
+    public String getPrivateKey()
+    {
+        return privateKey;
+    }
+
+    public void setPrivateKey( String privateKey )
+    {
+        this.privateKey = privateKey;
+    }
+
+    public String getPassphrase()
+    {
+        return passphrase;
+    }
+
+    public void setPassphrase( String passphrase )
+    {
+        this.passphrase = passphrase;
+    }
+
+    public boolean requiresEditMode()
         throws ScmException
     {
         ScmRepository repository = getScmRepository();



Mime
View raw message