geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r482714 - /geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java
Date Tue, 05 Dec 2006 17:18:30 GMT
Author: prasad
Date: Tue Dec  5 09:18:22 2006
New Revision: 482714

URL: http://svn.apache.org/viewvc?view=rev&rev=482714
Log:
* get authentication info from settings.xml file also.

Modified:
    geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java

Modified: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java?view=diff&rev=482714&r1=482713&r2=482714
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/ResultsSummaryMojo.java
Tue Dec  5 09:18:22 2006
@@ -53,6 +53,8 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.Server;
 
 import org.codehaus.plexus.util.FileUtils;
 
@@ -94,9 +96,18 @@
     protected MavenProject project = null;
 
     /**
+    * The build settings.
+    *
+    * @parameter expression="${settings}" default-value="${settings}
+    * @required
+    * @readonly
+    */
+    protected Settings settings;
+
+    /**
      * The username
      * 
-     * @parameter expression="${username}" default-value="${user.name}"
+     * @parameter expression="${username}"
      */
     private String username;
 
@@ -107,14 +118,22 @@
      */
     private String password;
 
+
     /**
      * The passphrase
      * 
-     * @parameter expression="${passphrase}" default-value=" "
+     * @parameter expression="${passphrase}"
      */
     private String passphrase;
 
     /**
+     * The keyfile
+     * 
+     * @parameter expression="${keyfile}"
+     */
+    private String keyFile;
+
+    /**
      * The passphrase
      * 
      * @parameter expression="${buildNumber}"
@@ -135,6 +154,8 @@
 
     private final String resultsFileName = "ResultsSummary.html";
 
+    private Server server;
+
     private Scp scp;
 
     protected MavenProject getProject()
@@ -148,19 +169,67 @@
         ant.setProject(getProject());
 
         scp = (Scp)ant.createTask("scp");
-        scp.setKeyfile("/home/" + username + "/.ssh/id_dsa");
 
-        if ( password != null )
-        {
-            scp.setPassword(password);
+
+        String siteId = project.getDistributionManagement().getSite().getId();
+        server = settings.getServer(siteId);
+
+        scp.setKeyfile(getKeyFile());
+
+        scp.setPassword(getPassword());
+        scp.setPassphrase(getPassphrase());
+        scp.setTrust(true);
+    }
+
+    private String getKeyFile() {
+       if (keyFile != null) {
+           return keyFile;
+       }
+       else if (server.getPrivateKey() != null) {
+           return server.getPrivateKey();
+       }
+
+       return "/home/" + getUsername() + "/.ssh/id_dsa";
+    }
+
+    private String getUsername() {
+       if (username != null) {
+           return username;
+       }
+       else if (server.getUsername() != null) {
+           return server.getUsername();
+       }
+
+       return System.getProperty("user.name");
+    }
+
+    private String getPassword() {
+        if (password != null) {
+            return password;
         }
-        else if ( passphrase != null )
-        {
-            scp.setPassphrase(passphrase);
+        else if (server.getPassword() != null) {
+            return server.getPassword();
         }
-        scp.setTrust(true);
+
+        return " ";
     }
 
+    private String getPassphrase() {
+        if (passphrase != null) {
+            return passphrase;
+        }
+        else if (server.getPassphrase() != null) {
+            return server.getPassphrase();
+        }
+
+        return " ";
+    }
+
+
+
+    /**
+     * called by execute from super
+     */
     protected void doExecute() throws Exception {
 
         File currentSiteDirectory = new File(targetDirectory, "/site");
@@ -281,7 +350,7 @@
 
 
         // construct the uri using username
-        remoteUri = username + "@" + remoteUri;
+        remoteUri = getUsername() + ":" + getPassword() + "@" + remoteUri;
         log.info("Remote uri is " + remoteUri);
 
         return remoteUri;



Mime
View raw message