maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager DefaultWagonManager.java WagonManager.java
Date Tue, 08 Feb 2005 07:48:08 GMT
brett       2005/02/07 23:48:08

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/manager
                        DefaultWagonManager.java WagonManager.java
  Log:
  ability to set a proxy for a wagon
  
  Revision  Changes    Path
  1.8       +41 -7     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
  
  Index: DefaultWagonManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultWagonManager.java	27 Dec 2004 05:11:29 -0000	1.7
  +++ DefaultWagonManager.java	8 Feb 2005 07:48:08 -0000	1.8
  @@ -17,11 +17,9 @@
    * ====================================================================
    */
   
  -import org.apache.maven.artifact.Artifact;
  -import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.artifact.AbstractArtifactComponent;
  +import org.apache.maven.artifact.Artifact;
   import org.apache.maven.artifact.DefaultArtifact;
  -import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.wagon.ConnectionException;
   import org.apache.maven.wagon.ResourceDoesNotExistException;
  @@ -30,18 +28,20 @@
   import org.apache.maven.wagon.Wagon;
   import org.apache.maven.wagon.authentication.AuthenticationException;
   import org.apache.maven.wagon.authorization.AuthorizationException;
  -import org.apache.maven.wagon.observers.ChecksumObserver;
  +import org.apache.maven.wagon.proxy.ProxyInfo;
   import org.codehaus.plexus.PlexusConstants;
   import org.codehaus.plexus.PlexusContainer;
  -import org.codehaus.plexus.util.FileUtils;
   import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
   import org.codehaus.plexus.context.Context;
   import org.codehaus.plexus.context.ContextException;
   import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
  +import org.codehaus.plexus.util.FileUtils;
   
   import java.io.File;
   import java.io.IOException;
  +import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.Map;
   import java.util.Set;
   
   public class DefaultWagonManager
  @@ -50,6 +50,8 @@
   {
       private PlexusContainer container;
   
  +    private Map proxies = new HashMap();
  +
       public Artifact createArtifact( String groupId, String artifactId, String version,
String type )
       {
           Artifact artifact = new DefaultArtifact( groupId, artifactId, version, type );
  @@ -85,7 +87,7 @@
       {
           Wagon wagon = getWagon( repository.getProtocol() );
   
  -        wagon.connect( repository );
  +        wagon.connect( repository, getProxy( repository.getProtocol() ) );
   
           wagon.put( source, path( artifact ) );
   
  @@ -156,7 +158,7 @@
   
                   //wagon.addTransferListener( md5SumObserver );
   
  -                wagon.connect( repository );
  +                wagon.connect( repository, getProxy( repository.getProtocol() ) );
   
                   wagon.get( path( artifact ), temp );
   
  @@ -232,6 +234,38 @@
           throw new TransferFailedException( "Unable to download the artifact from any repository"
);
       }
   
  +    private ProxyInfo getProxy( String protocol )
  +    {
  +        return (ProxyInfo) proxies.get( protocol );
  +    }
  +
  +    /**
  +     * Set the proxy used for a particular protocol.
  +     *
  +     * @todo [BP] would be nice to configure this via plexus in some way
  +     *
  +     * @param protocol the protocol (required)
  +     * @param host the proxy host name (required)
  +     * @param port the proxy port (required)
  +     * @param username the username for the proxy, or null if there is none
  +     * @param password the password for the proxy, or null if there is none
  +     * @param nonProxyHosts the set of hosts not to use the proxy for. Follows Java system
property format:
  +     *  <code>*.foo.com|localhost</code>.
  +     */
  +    public void setProxy( String protocol, String host, int port, String username, String
password,
  +                          String nonProxyHosts )
  +    {
  +        ProxyInfo proxyInfo = new ProxyInfo();
  +        proxyInfo.setHost( host );
  +        proxyInfo.setType( protocol );
  +        proxyInfo.setPort( port );
  +        proxyInfo.setNonProxyHosts( nonProxyHosts );
  +        proxyInfo.setUserName( username );
  +        proxyInfo.setPassword( password );
  +
  +        proxies.put( protocol, proxyInfo );
  +    }
  +
       public void contextualize( Context context )
           throws ContextException
       {
  
  
  
  1.3       +3 -3      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java
  
  Index: WagonManager.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/manager/WagonManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WagonManager.java	27 Dec 2004 05:11:29 -0000	1.2
  +++ WagonManager.java	8 Feb 2005 07:48:08 -0000	1.3
  @@ -18,8 +18,6 @@
    */
   
   import org.apache.maven.artifact.Artifact;
  -import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
  -import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.wagon.TransferFailedException;
   import org.apache.maven.wagon.UnsupportedProtocolException;
  @@ -49,5 +47,7 @@
       void put( File source, Artifact artifact, ArtifactRepository deploymentRepository )
           throws Exception;
   
  +    void setProxy( String protocol, String host, int port, String username, String password,
String nonProxyHosts );
  +
       Artifact createArtifact( String groupId, String artifactId, String version, String
type );
   }
  \ No newline at end of file
  
  
  

Mime
View raw message