You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2015/04/02 06:50:01 UTC

maven git commit: MNG-5795: Maven extensions can not be retrieved from authenticated repositories

Repository: maven
Updated Branches:
  refs/heads/master f78742f3e -> 56e6db123


MNG-5795: Maven extensions can not be retrieved from authenticated repositories


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/56e6db12
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/56e6db12
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/56e6db12

Branch: refs/heads/master
Commit: 56e6db123150d08c15f1920ed8cc571480161b3c
Parents: f78742f
Author: Jason van Zyl <ja...@tesla.io>
Authored: Thu Apr 2 00:21:00 2015 -0400
Committer: Jason van Zyl <ja...@tesla.io>
Committed: Thu Apr 2 00:49:50 2015 -0400

----------------------------------------------------------------------
 .../DefaultMavenExecutionRequestPopulator.java  | 259 ++++++++-----------
 .../MavenExecutionRequestPopulator.java         |  31 ++-
 .../DefaultRepositorySystemSessionFactory.java  |  12 +
 .../SettingsXmlConfigurationProcessor.java      |  20 +-
 4 files changed, 138 insertions(+), 184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/56e6db12/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
index edb29ce..7568fde 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequestPopulator.java
@@ -62,107 +62,6 @@ public class DefaultMavenExecutionRequestPopulator
         this.repositorySystem = repositorySystem;
     }
 
-    @Override
-    public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
-        throws MavenExecutionRequestPopulationException
-    {
-        if ( settings == null )
-        {
-            return request;
-        }
-
-        request.setOffline( settings.isOffline() );
-
-        request.setInteractiveMode( settings.isInteractiveMode() );
-
-        request.setPluginGroups( settings.getPluginGroups() );
-
-        request.setLocalRepositoryPath( settings.getLocalRepository() );
-
-        for ( Server server : settings.getServers() )
-        {
-            server = server.clone();
-
-            request.addServer( server );
-        }
-
-        //  <proxies>
-        //    <proxy>
-        //      <active>true</active>
-        //      <protocol>http</protocol>
-        //      <host>proxy.somewhere.com</host>
-        //      <port>8080</port>
-        //      <username>proxyuser</username>
-        //      <password>somepassword</password>
-        //      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
-        //    </proxy>
-        //  </proxies>
-
-        for ( Proxy proxy : settings.getProxies() )
-        {
-            if ( !proxy.isActive() )
-            {
-                continue;
-            }
-
-            proxy = proxy.clone();
-
-            request.addProxy( proxy );
-        }
-
-        // <mirrors>
-        //   <mirror>
-        //     <id>nexus</id>
-        //     <mirrorOf>*</mirrorOf>
-        //     <url>http://repository.sonatype.org/content/groups/public</url>
-        //   </mirror>
-        // </mirrors>
-
-        for ( Mirror mirror : settings.getMirrors() )
-        {
-            mirror = mirror.clone();
-
-            request.addMirror( mirror );
-        }
-
-        request.setActiveProfiles( settings.getActiveProfiles() );
-
-        for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
-        {
-            request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) );
-
-            if ( settings.getActiveProfiles().contains( rawProfile.getId() ) )
-            {
-                List<Repository> remoteRepositories = rawProfile.getRepositories();
-                for ( Repository remoteRepository : remoteRepositories )
-                {
-                    try
-                    {
-                        request.addRemoteRepository( repositorySystem.buildArtifactRepository( remoteRepository ) );
-                    }
-                    catch ( InvalidRepositoryException e )
-                    {
-                        // do nothing for now
-                    }
-                }
-
-                List<Repository> pluginRepositories = rawProfile.getPluginRepositories();
-                for ( Repository pluginRepo : pluginRepositories )
-                {
-                    try
-                    {
-                        request.addPluginArtifactRepository( repositorySystem.buildArtifactRepository( pluginRepo ) );
-                    }
-                    catch ( InvalidRepositoryException e )
-                    {
-                        // do nothing for now
-                    }
-                }
-            }
-        }
-
-        return request;
-    }
 
     @Override
     public MavenExecutionRequest populateFromToolchains( MavenExecutionRequest request, PersistedToolchains toolchains )
@@ -201,8 +100,6 @@ public class DefaultMavenExecutionRequestPopulator
 
         injectDefaultPluginRepositories( request );
 
-        processRepositoriesInSettings( request );
-
         return request;
     }
     
@@ -252,54 +149,6 @@ public class DefaultMavenExecutionRequestPopulator
         }
     }
 
-    private void processRepositoriesInSettings( MavenExecutionRequest request )
-        throws MavenExecutionRequestPopulationException
-    {
-        //
-        //    <settings>
-        //      <mirrors>
-        //        <mirror>
-        //          <id>central</id>
-        //          <!-- NOTE: We need to try and use the proper host name/ip as Java generally ignores proxies for
-        //                     "localhost" -->
-        //          <url>http://10.0.1.34:62247/</url>
-        //          <mirrorOf>central</mirrorOf>
-        //        </mirror>
-        //      </mirrors>
-        //      <proxies>
-        //        <proxy>
-        //          <active>true</active>
-        //          <protocol>http</protocol>
-        //          <host>localhost</host>
-        //          <port>62248</port>
-        //          <nonProxyHosts>10.0.1.34</nonProxyHosts>
-        //        </proxy>
-        //      </proxies>
-        //      <profiles>
-        //        <profile>
-        //          <id>it-defaults</id>
-        //          <!-- disable central override and use built-in values -->
-        //        </profile>
-        //      </profiles>
-        //      <activeProfiles>
-        //        <activeProfile>it-defaults</activeProfile>
-        //      </activeProfiles>
-        //    </settings>
-        //
-        // Turns
-        //
-        // http://repo1.maven.org/maven2
-        //
-        // to
-        //
-        // http://10.0.1.34:62247/
-        //
-        // Not sure why the DefaultMirrorSelector doesn't do this...
-        //
-        repositorySystem.injectMirror( request.getRemoteRepositories(), request.getMirrors() );
-        repositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() );
-    }
-
     private void localRepository( MavenExecutionRequest request )
         throws MavenExecutionRequestPopulationException
     {
@@ -358,4 +207,112 @@ public class DefaultMavenExecutionRequestPopulator
             request.setBaseDirectory( request.getPom().getAbsoluteFile().getParentFile() );
         }
     }   
+    
+    /*if_not[MAVEN4]*/
+    
+    @Override
+    @Deprecated
+    public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
+        throws MavenExecutionRequestPopulationException
+    {
+        if ( settings == null )
+        {
+            return request;
+        }
+
+        request.setOffline( settings.isOffline() );
+
+        request.setInteractiveMode( settings.isInteractiveMode() );
+
+        request.setPluginGroups( settings.getPluginGroups() );
+
+        request.setLocalRepositoryPath( settings.getLocalRepository() );
+
+        for ( Server server : settings.getServers() )
+        {
+            server = server.clone();
+
+            request.addServer( server );
+        }
+
+        //  <proxies>
+        //    <proxy>
+        //      <active>true</active>
+        //      <protocol>http</protocol>
+        //      <host>proxy.somewhere.com</host>
+        //      <port>8080</port>
+        //      <username>proxyuser</username>
+        //      <password>somepassword</password>
+        //      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
+        //    </proxy>
+        //  </proxies>
+
+        for ( Proxy proxy : settings.getProxies() )
+        {
+            if ( !proxy.isActive() )
+            {
+                continue;
+            }
+
+            proxy = proxy.clone();
+
+            request.addProxy( proxy );
+        }
+
+        // <mirrors>
+        //   <mirror>
+        //     <id>nexus</id>
+        //     <mirrorOf>*</mirrorOf>
+        //     <url>http://repository.sonatype.org/content/groups/public</url>
+        //   </mirror>
+        // </mirrors>
+
+        for ( Mirror mirror : settings.getMirrors() )
+        {
+            mirror = mirror.clone();
+
+            request.addMirror( mirror );
+        }
+
+        request.setActiveProfiles( settings.getActiveProfiles() );
+
+        for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
+        {
+            request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) );
+
+            if ( settings.getActiveProfiles().contains( rawProfile.getId() ) )
+            {
+                List<Repository> remoteRepositories = rawProfile.getRepositories();
+                for ( Repository remoteRepository : remoteRepositories )
+                {
+                    try
+                    {
+                        request.addRemoteRepository( repositorySystem.buildArtifactRepository( remoteRepository ) );
+                    }
+                    catch ( InvalidRepositoryException e )
+                    {
+                        // do nothing for now
+                    }
+                }
+
+                List<Repository> pluginRepositories = rawProfile.getPluginRepositories();
+                for ( Repository pluginRepo : pluginRepositories )
+                {
+                    try
+                    {
+                        request.addPluginArtifactRepository( repositorySystem.buildArtifactRepository( pluginRepo ) );
+                    }
+                    catch ( InvalidRepositoryException e )
+                    {
+                        // do nothing for now
+                    }
+                }
+            }
+        }
+
+        return request;
+    }    
+    
+    /*end[MAVEN4]*/
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/56e6db12/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
index 9efc019..4f254f7 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequestPopulator.java
@@ -29,43 +29,46 @@ import org.apache.maven.toolchain.model.PersistedToolchains;
  */
 public interface MavenExecutionRequestPopulator
 {
-
     /**
-     * Copies the values from the given settings into the specified execution request. This method will replace any
-     * existing values in the execution request that are controlled by the settings. Hence, it is expected that this
+     * Copies the values from the given toolchains into the specified execution request. This method will replace any
+     * existing values in the execution request that are controlled by the toolchains. Hence, it is expected that this
      * method is called on a new/empty execution request before the caller mutates it to fit its needs.
      *
      * @param request The execution request to populate, must not be {@code null}.
-     * @param settings The settings to copy into the execution request, may be {@code null}.
+     * @param toolchains The toolchains to copy into the execution request, may be {@code null}.
      * @return The populated execution request, never {@code null}.
      * @throws MavenExecutionRequestPopulationException If the execution request could not be populated.
+     * @since 3.3.0
      */
-    @Deprecated
-    MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
+    MavenExecutionRequest populateFromToolchains( MavenExecutionRequest request, PersistedToolchains toolchains )
         throws MavenExecutionRequestPopulationException;
 
     /**
-     * Copies the values from the given toolchains into the specified execution request. This method will replace any
-     * existing values in the execution request that are controlled by the toolchains. Hence, it is expected that this
-     * method is called on a new/empty execution request before the caller mutates it to fit its needs.
+     * Injects default values like plugin groups or repositories into the specified execution request.
      *
      * @param request The execution request to populate, must not be {@code null}.
-     * @param toolchains The toolchains to copy into the execution request, may be {@code null}.
      * @return The populated execution request, never {@code null}.
      * @throws MavenExecutionRequestPopulationException If the execution request could not be populated.
-     * @since 3.3.0
      */
-    MavenExecutionRequest populateFromToolchains( MavenExecutionRequest request, PersistedToolchains toolchains )
+    MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
         throws MavenExecutionRequestPopulationException;
 
+    /*if_not[MAVEN4]*/
+    
     /**
-     * Injects default values like plugin groups or repositories into the specified execution request.
+     * Copies the values from the given settings into the specified execution request. This method will replace any
+     * existing values in the execution request that are controlled by the settings. Hence, it is expected that this
+     * method is called on a new/empty execution request before the caller mutates it to fit its needs.
      *
      * @param request The execution request to populate, must not be {@code null}.
+     * @param settings The settings to copy into the execution request, may be {@code null}.
      * @return The populated execution request, never {@code null}.
      * @throws MavenExecutionRequestPopulationException If the execution request could not be populated.
      */
-    MavenExecutionRequest populateDefaults( MavenExecutionRequest request )
+    @Deprecated
+    MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
         throws MavenExecutionRequestPopulationException;
 
+    /*end[MAVEN4]*/
+
 }

http://git-wip-us.apache.org/repos/asf/maven/blob/56e6db12/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
index 6197f0f..26a8dda 100644
--- a/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
+++ b/maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java
@@ -30,6 +30,7 @@ import javax.inject.Named;
 
 import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.bridge.MavenRepositorySystem;
 import org.apache.maven.eventspy.internal.EventSpyDispatcher;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
@@ -91,6 +92,9 @@ public class DefaultRepositorySystemSessionFactory
     @Inject
     private EventSpyDispatcher eventSpyDispatcher;
 
+    @Inject
+    MavenRepositorySystem mavenRepositorySystem;
+    
     public DefaultRepositorySystemSession newRepositorySession( MavenExecutionRequest request )
     {
         DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
@@ -226,6 +230,14 @@ public class DefaultRepositorySystemSessionFactory
         session.setSystemProperties( request.getSystemProperties() );
         session.setConfigProperties( configProps );
 
+        mavenRepositorySystem.injectMirror( request.getRemoteRepositories(), request.getMirrors() );
+        mavenRepositorySystem.injectProxy( session, request.getRemoteRepositories() );
+        mavenRepositorySystem.injectAuthentication( session, request.getRemoteRepositories() );
+
+        mavenRepositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors() );        
+        mavenRepositorySystem.injectProxy( session, request.getPluginArtifactRepositories() );
+        mavenRepositorySystem.injectAuthentication( session, request.getPluginArtifactRepositories() );
+
         return session;
     }
 

http://git-wip-us.apache.org/repos/asf/maven/blob/56e6db12/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
index 890a658..791a226 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java
@@ -42,9 +42,7 @@ import org.apache.maven.settings.building.SettingsBuilder;
 import org.apache.maven.settings.building.SettingsBuildingRequest;
 import org.apache.maven.settings.building.SettingsBuildingResult;
 import org.apache.maven.settings.building.SettingsProblem;
-import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
 import org.apache.maven.settings.crypto.SettingsDecrypter;
-import org.apache.maven.settings.crypto.SettingsDecryptionResult;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.slf4j.Logger;
@@ -156,25 +154,9 @@ public class SettingsXmlConfigurationProcessor
             }
             logger.warn( "" );
         }
-
-        DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
-        decrypt.setProxies( request.getProxies() );
-        decrypt.setServers( request.getServers() );
-        SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt );
-
-        if ( logger.isDebugEnabled() )
-        {
-            for ( SettingsProblem problem : decrypted.getProblems() )
-            {
-                logger.debug( problem.getMessage(), problem.getException() );
-            }
-        }
-
-        request.setProxies( decrypt.getProxies() );
-        request.setServers( decrypt.getServers() );
     }
 
-    public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
+    private MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
         throws MavenExecutionRequestPopulationException
     {
         if ( settings == null )