maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mkle...@apache.org
Subject svn commit: r434079 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/DefaultMaven.java maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
Date Wed, 23 Aug 2006 16:58:35 GMT
Author: mkleint
Date: Wed Aug 23 09:58:33 2006
New Revision: 434079

URL: http://svn.apache.org/viewvc?rev=434079&view=rev
Log:
MNG-1884 - the wagon manager needs to be injects the proxy/mirror info, otherwise the readProject()
calls don't get through the firewalls.

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=434079&r1=434078&r2=434079&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Wed
Aug 23 09:58:33 2006
@@ -617,6 +617,8 @@
      * them in. It doesn't feel quite right.
      * @todo [JC] we should at least provide a mapping of protocol-to-proxy for
      * the wagons, shouldn't we?
+     * @todo [mkleint] as part of fix MNG-1884, I've copied this code into 
+     * MavenEmbedder. if rewritten, needs to be rewritten there too
      */
     private void resolveParameters( Settings settings )
         throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java?rev=434079&r1=434078&r2=434079&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
Wed Aug 23 09:58:33 2006
@@ -43,6 +43,9 @@
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.reactor.MavenExecutionException;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Server;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.wagon.events.TransferListener;
 import org.codehaus.classworlds.ClassWorld;
@@ -55,6 +58,7 @@
 import org.codehaus.plexus.configuration.PlexusConfigurationException;
 import org.codehaus.plexus.embed.Embedder;
 import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -632,6 +636,8 @@
                                                  null );
 
             profileManager.loadSettingsProfiles( settings );
+            
+            resolveParameters( settings );
     
             started = true;
             
@@ -653,8 +659,59 @@
         catch (SettingsConfigurationException e ) 
         {
             throw new MavenEmbedderException( "Cannot create settings configuration", e );
+        } 
+    }
+    
+    /**
+     * MKLEINT: copied from DefaultMaven. the wagonManager was not injected with proxy info
+     * when called in non-execute mode..
+     * 
+     * @todo [BP] this might not be required if there is a better way to pass
+     * them in. It doesn't feel quite right.
+     * @todo [JC] we should at least provide a mapping of protocol-to-proxy for
+     * the wagons, shouldn't we?
+     */
+    private void resolveParameters( Settings settings )
+        throws SettingsConfigurationException
+    {
+        
+        Proxy proxy = settings.getActiveProxy();
+        
+        if ( proxy != null ) 
+        {
+            if ( proxy.getHost() == null ) 
+            {
+                throw new SettingsConfigurationException( "Proxy in settings.xml has no host"
);
+            }
+            System.out.println("setting proxy to=" + proxy.getHost());
+            wagonManager.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(),
proxy.getUsername(),
+                    proxy.getPassword(), proxy.getNonProxyHosts() );
+        }
+        
+        for ( Iterator i = settings.getServers().iterator(); i.hasNext(); ) 
+        {
+            Server server = (Server) i.next();
+            
+            wagonManager.addAuthenticationInfo( server.getId(), server.getUsername(), server.getPassword(),
+                    server.getPrivateKey(), server.getPassphrase() );
+            
+            wagonManager.addPermissionInfo( server.getId(), server.getFilePermissions(),
+                    server.getDirectoryPermissions() );
+            
+            if ( server.getConfiguration() != null ) 
+            {
+                wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration()
);
+            }
+        }
+        
+        for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); ) 
+        {
+            Mirror mirror = (Mirror) i.next();
+            
+            wagonManager.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl()
);
         }
     }
+    
 
 
     // ----------------------------------------------------------------------



Mime
View raw message