Author: ltheussl
Date: Wed Jul 19 10:56:15 2006
New Revision: 423546

URL: http://svn.apache.org/viewvc?rev=423546&view=rev
Log:
PR: MAVEN-1686
Submitted by: Juan F. Codagnone
Support for sftp in maven.repo.remote.

Modified:
    maven/maven-1/core/trunk/project.xml
    
maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java
    maven/maven-1/core/trunk/xdocs/using/repositories.xml

Modified: maven/maven-1/core/trunk/project.xml
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/project.xml?rev=423546&r1=423545&r2=423546&view=diff
==============================================================================
--- maven/maven-1/core/trunk/project.xml (original)
+++ maven/maven-1/core/trunk/project.xml Wed Jul 19 10:56:15 2006
@@ -687,6 +687,11 @@
       <artifactId>wagon-file</artifactId>
       <version>1.0-beta-1</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.wagon</groupId>
+      <artifactId>wagon-ssh</artifactId>
+      <version>1.0-beta-1</version>
+    </dependency>
     <!-- Runtime dependencies -->
     <dependency>
       <groupId>commons-beanutils</groupId>
@@ -708,6 +713,14 @@
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
       <version>2.0</version>
+      <properties>
+        <scope>runtime</scope>
+      </properties>
+    </dependency>
+    <dependency>
+      <groupId>com.jcraft</groupId>
+      <artifactId>jsch</artifactId>
+      <version>0.1.27</version>
       <properties>
         <scope>runtime</scope>
       </properties>

Modified: 
maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java?rev=423546&r1=423545&r2=423546&view=diff
==============================================================================
--- 
maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java
 (original)
+++ 
maven/maven-1/core/trunk/src/java/org/apache/maven/verifier/DependencyVerifier.java
 Wed Jul 19 10:56:15 2006
@@ -20,9 +20,11 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.security.NoSuchAlgorithmException;
 
@@ -44,6 +46,7 @@
 import org.apache.maven.wagon.observers.ChecksumObserver;
 import org.apache.maven.wagon.providers.file.FileWagon;
 import org.apache.maven.wagon.providers.http.HttpWagon;
+import org.apache.maven.wagon.providers.ssh.SftpWagon;
 import org.apache.maven.wagon.proxy.ProxyInfo;
 import org.apache.maven.wagon.repository.Repository;
 import org.codehaus.plexus.util.FileUtils;
@@ -382,18 +385,12 @@
         {
             String remoteRepo = (String) i.next();
 
-            Repository repository = new Repository( "repo" + count, 
remoteRepo.trim() );
+            Repository repository =
+                new Repository( "repo" + count, remoteRepo.trim() );
+
+            final Wagon wagon =
+                new DefaultWagonFactory().getWagon( repository.getProtocol() );
 
-            // TODO: would like not to have to initialise the wagons all the 
time - use a session
-            Wagon wagon;
-            if ( repository.getProtocol().equals( "http" ) || 
repository.getProtocol().equals( "https" ) )
-            {
-                wagon = new HttpWagon();
-            }
-            else
-            {
-                wagon = new FileWagon();
-            }
 
             if ( listener != null )
             {
@@ -594,6 +591,48 @@
         }
 
         return artifactFound;
+    }
+
+    /**
+     * Creates Wagons. Replace it with a IoC container?
+     */
+    private static class DefaultWagonFactory {
+
+        private final Map map = new HashMap();
+
+        public DefaultWagonFactory() 
+        {
+            map.put( "http", HttpWagon.class );
+            map.put( "https", HttpWagon.class );
+            map.put( "sftp", SftpWagon.class );
+            map.put( "file", FileWagon.class );
+        }
+
+        public final Wagon getWagon( final String protocol ) 
+        {
+            // TODO: don't initialise the wagons all the time - use a session
+            Wagon ret;
+            final Class aClass = (Class) map.get( protocol );
+            if ( aClass == null ) 
+            {
+                log.info( "Unknown protocol: `" + protocol
+                        + "'. Trying file wagon" );
+                ret = new FileWagon();
+            }
+            else 
+            {
+                try 
+                {
+                    ret = (Wagon) aClass.newInstance();
+                } 
+                catch ( final Exception e ) 
+                {
+                    throw new RuntimeException( e );
+                }
+            }
+
+            return ret;
+        }
     }
 
     // ----------------------------------------------------------------------

Modified: maven/maven-1/core/trunk/xdocs/using/repositories.xml
URL: 
http://svn.apache.org/viewvc/maven/maven-1/core/trunk/xdocs/using/repositories.xml?rev=423546&r1=423545&r2=423546&view=diff
==============================================================================
--- maven/maven-1/core/trunk/xdocs/using/repositories.xml (original)
+++ maven/maven-1/core/trunk/xdocs/using/repositories.xml Wed Jul 19 10:56:15 
2006
@@ -104,6 +104,12 @@
           have not overridden the remote repository.
         </p>
         <p>
+          The protocols that are currently supported for a remote repository 
are <code>http</code>,
+          <code>https</code>, <code>sftp</code> and <code>file</code>. Note 
that <code>sftp</code>
+          is only supported since Maven 1.1-beta-3, and you'll have to set the 
username and password in the url, eg:
+        </p>
+        <source>maven.repo.remote=sftp://${myusername}:[EMAIL 
PROTECTED]/tmp/ble</source>
+        <p>
           (Future versions should allow you to use a setting of
           <code>${maven.repo.remote},http://anothermavenrepository</code>, but 
currently this causes an infinite 
           recursion).


Reply via email to