maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r810296 - in /maven/components/trunk: ./ maven-compat/ maven-compat/src/main/java/org/apache/maven/project/ maven-compat/src/main/java/org/apache/maven/repository/ maven-compat/src/main/mdo/ maven-compat/src/test/java/org/apache/maven/repos...
Date Tue, 01 Sep 2009 22:49:06 GMT
Author: bentmann
Date: Tue Sep  1 22:49:05 2009
New Revision: 810296

URL: http://svn.apache.org/viewvc?rev=810296&view=rev
Log:
[MNG-4334] maven core caches settings.xml

o First pass: auth & mirror moved out of the components into the requests

Added:
    maven/components/trunk/maven-compat/src/main/mdo/settings.mdo
      - copied unchanged from r810165, maven/components/trunk/maven-core/src/main/mdo/settings.mdo
Removed:
    maven/components/trunk/maven-core/src/main/mdo/settings.mdo
Modified:
    maven/components/trunk/build.xml
    maven/components/trunk/maven-compat/pom.xml
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java
    maven/components/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
    maven/components/trunk/maven-core/pom.xml
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java

Modified: maven/components/trunk/build.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/build.xml?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/build.xml (original)
+++ maven/components/trunk/build.xml Tue Sep  1 22:49:05 2009
@@ -181,7 +181,7 @@
     <modello file="maven-model/src/main/mdo/maven.mdo" version="4.0.0" />
     <modello file="maven-plugin-api/src/main/mdo/lifecycle.mdo" />
     <modello file="maven-model-builder/src/main/mdo/profiles.mdo" />
-    <modello file="maven-core/src/main/mdo/settings.mdo" />
+    <modello file="maven-compat/src/main/mdo/settings.mdo" />
     <modello file="maven-core/src/main/mdo/toolchains.mdo" />
     <modello file="maven-compat/src/main/mdo/metadata.mdo" />
     <modello file="maven-compat/src/main/mdo/profiles.mdo" />

Modified: maven/components/trunk/maven-compat/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/pom.xml?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/pom.xml (original)
+++ maven/components/trunk/maven-compat/pom.xml Tue Sep  1 22:49:05 2009
@@ -79,6 +79,7 @@
             <model>src/main/mdo/metadata.mdo</model>
             <model>src/main/mdo/profiles.mdo</model>
             <model>src/main/mdo/paramdoc.mdo</model>
+            <model>src/main/mdo/settings.mdo</model>
           </models>
         </configuration>
       </plugin>

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/ProjectUtils.java
Tue Sep  1 22:49:05 2009
@@ -34,9 +34,9 @@
 // This class needs to stick around because it was exposed the the remote resources plugin
started using it instead of
 // getting the repositories from the project.
 
+@Deprecated
 public final class ProjectUtils
 {
-    static RepositorySystem rs;
         
     private ProjectUtils()
     {
@@ -53,7 +53,10 @@
             remoteRepositories.add( buildArtifactRepository( r, artifactRepositoryFactory,
c ) );
         }
 
-        remoteRepositories = rs( c ).getMirrors( remoteRepositories );
+        /*
+         * FIXME: The bad dependency relation between maven-core and maven-compat prevents
access to LegacySupport here
+         * which is required to get the mirror&authentication settings from the session/request.
+         */
 
         return remoteRepositories;
     }
@@ -61,6 +64,10 @@
     public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository
repo, ArtifactRepositoryFactory artifactRepositoryFactory, PlexusContainer c )
         throws InvalidRepositoryException
     {
+        /*
+         * FIXME: The bad dependency relation between maven-core and maven-compat prevents
access to LegacySupport here
+         * which is required to get the authentication settings from the session/request.
+         */
         return rs( c ).buildArtifactRepository( repo );
     }
 
@@ -74,12 +81,12 @@
     {
         try
         {
-            rs = c.lookup( RepositorySystem.class );
+            return c.lookup( RepositorySystem.class );
         }
         catch ( ComponentLookupException e )
         {
+            throw new IllegalStateException( e );
         }
-        
-        return rs;
     }
+
 }

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/DefaultMirrorBuilder.java
Tue Sep  1 22:49:05 2009
@@ -163,7 +163,7 @@
      * @param pattern used for match. Currently only '*' is supported.
      * @return true if the repository is a match to this pattern.
      */
-    boolean matchPattern( ArtifactRepository originalRepository, String pattern )
+    static boolean matchPattern( ArtifactRepository originalRepository, String pattern )
     {
         boolean result = false;
         String originalId = originalRepository.getId();
@@ -218,7 +218,7 @@
      * @param originalRepository
      * @return true if external.
      */
-    boolean isExternalRepo( ArtifactRepository originalRepository )
+    static boolean isExternalRepo( ArtifactRepository originalRepository )
     {
         try
         {

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/LegacyRepositorySystem.java
Tue Sep  1 22:49:05 2009
@@ -47,9 +47,10 @@
 import org.apache.maven.repository.LocalArtifactRepository;
 import org.apache.maven.repository.MetadataResolutionRequest;
 import org.apache.maven.repository.MetadataResolutionResult;
-import org.apache.maven.repository.MirrorBuilder;
 import org.apache.maven.repository.RepositorySystem;
 import org.apache.maven.repository.legacy.WagonManager;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Server;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.events.TransferListener;
@@ -77,9 +78,6 @@
 
     @Requirement( role = ArtifactRepositoryLayout.class )
     private Map<String, ArtifactRepositoryLayout> layouts;
-    
-    @Requirement
-    private MirrorBuilder mirrorBuilder;
 
     @Requirement
     private WagonManager wagonManager;
@@ -87,10 +85,9 @@
     @Requirement
     private PlexusContainer plexus;
 
-    private Map<String, Authentication> authentications = new HashMap<String, Authentication>();
-
+    // TODO: move this out, the component needs to be stateless for safe reuse
     private Map<String, Proxy> proxies = new HashMap<String,Proxy>();
-    
+
     public Artifact createArtifact( String groupId, String artifactId, String version, String
scope, String type )
     {
         return artifactFactory.createArtifact( groupId, artifactId, version, scope, type
);
@@ -329,18 +326,6 @@
     }
     */
 
-    // Mirror 
-    public void addMirror( String id, String mirrorOf, String url )
-    {
-        Authentication auth = id != null ? authentications.get( id ) : null;
-        mirrorBuilder.addMirror( id, mirrorOf, url, auth );
-    }
-
-    public List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories
)
-    {
-        return mirrorBuilder.getMirrors( repositories );
-    }
-
     public List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository>
repositories )
     {
         if ( repositories == null )
@@ -392,6 +377,8 @@
             ArtifactRepository effectiveRepository = 
                 createArtifactRepository( aliasedRepo.getId(), aliasedRepo.getUrl(), aliasedRepo.getLayout(),
snapshotPolicy, releasePolicy );
 
+            effectiveRepository.setAuthentication( aliasedRepo.getAuthentication() );
+
             effectiveRepositories.add( effectiveRepository );
         }
 
@@ -466,6 +453,84 @@
         }
     }
 
+    private Mirror getMirror( ArtifactRepository repository, List<Mirror> mirrors )
+    {
+        String repoId = repository.getId();
+
+        if ( repoId != null )
+        {
+            for ( Mirror mirror : mirrors )
+            {
+                if ( repoId.equals( mirror.getMirrorOf() ) )
+                {
+                    return mirror;
+                }
+            }
+
+            for ( Mirror mirror : mirrors )
+            {
+                if ( DefaultMirrorBuilder.matchPattern( repository, mirror.getMirrorOf()
) )
+                {
+                    return mirror;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    public void injectMirror( List<ArtifactRepository> repositories, List<Mirror>
mirrors )
+    {
+        if ( repositories != null && mirrors != null )
+        {
+            for ( ArtifactRepository repository : repositories )
+            {
+                Mirror mirror = getMirror( repository, mirrors );
+
+                if ( mirror != null )
+                {
+                    repository.setId( mirror.getId() );
+                    repository.setUrl( mirror.getUrl() );
+                }
+            }
+        }
+    }
+
+    public void injectAuthentication( List<ArtifactRepository> repositories, List<Server>
servers )
+    {
+        if ( repositories != null )
+        {
+            Map<String, Server> serversById = new HashMap<String, Server>();
+
+            if ( servers != null )
+            {
+                for ( Server server : servers )
+                {
+                    if ( !serversById.containsKey( server.getId() ) )
+                    {
+                        serversById.put( server.getId(), server );
+                    }
+                }
+            }
+
+            for ( ArtifactRepository repository : repositories )
+            {
+                Server server = serversById.get( repository.getId() );
+
+                if ( server != null )
+                {
+                    Authentication authentication = new Authentication( server.getUsername(),
server.getPassword() );
+
+                    repository.setAuthentication( authentication );
+                }
+                else
+                {
+                    repository.setAuthentication( null );
+                }
+            }
+        }
+    }
+
     public MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request )
     {
 
@@ -496,15 +561,6 @@
     }
 
     //
-    // serverId = repository id
-    //
-    public void addAuthenticationForArtifactRepository( String repositoryId, String username,
String password )
-    {
-        Authentication authentication = new Authentication( username, password );
-        authentications.put( repositoryId, authentication );
-    }
-
-    //
     // Artifact Repository Creation
     //
     public ArtifactRepository buildArtifactRepository( Repository repo )
@@ -556,14 +612,7 @@
 
         ArtifactRepository artifactRepository = artifactRepositoryFactory.createArtifactRepository(
repositoryId, url, repositoryLayout, snapshots, releases );
 
-        Authentication authentication = authentications.get( repositoryId );
-        
-        if ( authentication != null )
-        {
-            artifactRepository.setAuthentication( authentication );
-        }
-        
-        Proxy proxy = proxies.get(  artifactRepository.getProtocol() );
+        Proxy proxy = proxies.get( artifactRepository.getProtocol() );
         
         if ( proxy != null )
         {

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/repository/RepositorySystem.java
Tue Sep  1 22:49:05 2009
@@ -32,6 +32,8 @@
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Repository;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Server;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.events.TransferListener;
@@ -90,14 +92,31 @@
      */
     List<ArtifactRepository> getEffectiveRepositories( List<ArtifactRepository>
repositories );    
 
+    /**
+     * Injects the mirroring information into the specified repositories. For each repository
that is matched by a
+     * mirror, its URL and ID will be updated to match the values from the mirror specification.
Repositories without a
+     * matching mirror will pass through unchanged. <em>Note:</em> This method
must be called before
+     * {@link #injectAuthentication(List, List)} or the repositories will end up with the
wrong credentials.
+     * 
+     * @param repositories The repositories into which to inject the mirror information,
may be {@code null}.
+     * @param mirrors The available mirrors, may be {@code null}.
+     */
+    void injectMirror( List<ArtifactRepository> repositories, List<Mirror> mirrors
);
+
+    /**
+     * Injects the authentication information into the specified repositories. For each repository
that is matched by a
+     * server, its credentials will be updated to match the values from the server specification.
Repositories without a
+     * matching server will have their credentials cleared. <em>Note:</em> This
method must be called before
+     * {@link #injectAuthentication(List, List)} or the repositories will end up with the
wrong credentials.
+     * 
+     * @param repositories The repositories into which to inject the authentication information,
may be {@code null}.
+     * @param servers The available servers, may be {@code null}.
+     */
+    void injectAuthentication( List<ArtifactRepository> repositories, List<Server>
servers );
+
     ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
 
     MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
-           
-    //TODO: remove the request should already be processed to select the mirror for the request
instead of the processing happen internally.
-    // Mirrors    
-    void addMirror( String id, String mirrorOf, String url );        
-    List<ArtifactRepository> getMirrors( List<ArtifactRepository> repositories
);  
     
     // Install
     
@@ -113,8 +132,6 @@
     
     void retrieve( ArtifactRepository repository, File destination, String remotePath, TransferListener
downloadMonitor )
         throws TransferFailedException, ResourceDoesNotExistException; 
-        
-    void addAuthenticationForArtifactRepository( String repositoryId, String username, String
password );
 
     void addProxy( String protocol, String host, int port, String username, String password,
String nonProxyHosts );    
 }

Modified: maven/components/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
(original)
+++ maven/components/trunk/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java
Tue Sep  1 22:49:05 2009
@@ -16,18 +16,13 @@
  */
 
 import java.io.File;
-import java.lang.reflect.Array;
 import java.util.Arrays;
-import java.util.Collections;
 
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.Authentication;
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.model.Dependency;
 import org.apache.maven.repository.LegacyRepositorySystem;
 import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Server;
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -67,11 +62,18 @@
     public void testAuthenticationHandling()
         throws Exception
     {
-        repositorySystem.addAuthenticationForArtifactRepository( "repository", "jason", "abc123"
);
-        ArtifactRepository repository = repositorySystem.createArtifactRepository( "repository",
"http://foo", null, null, null );
+        Server server = new Server();
+        server.setId( "repository" );
+        server.setUsername( "jason" );
+        server.setPassword( "abc123" );
+
+        ArtifactRepository repository =
+            repositorySystem.createArtifactRepository( "repository", "http://foo", null,
null, null );
+        repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList(
server ) );
         Authentication authentication = repository.getAuthentication();
         assertNotNull( authentication );
         assertEquals( "jason", authentication.getUsername() );
         assertEquals( "abc123", authentication.getPassword() );
     }
+
 }

Modified: maven/components/trunk/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/pom.xml?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/pom.xml (original)
+++ maven/components/trunk/maven-core/pom.xml Tue Sep  1 22:49:05 2009
@@ -103,7 +103,6 @@
         <configuration>
           <version>1.0.0</version>
           <models>
-            <model>src/main/mdo/settings.mdo</model>
             <model>src/main/mdo/toolchains.mdo</model>
           </models>
         </configuration>

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
Tue Sep  1 22:49:05 2009
@@ -965,6 +965,8 @@
             projectBuildingRequest.setPluginArtifactRepositories( getPluginArtifactRepositories()
);
             projectBuildingRequest.setRepositoryCache( getRepositoryCache() );
             projectBuildingRequest.setOffline( isOffline() );
+            projectBuildingRequest.setServers( getServers() );
+            projectBuildingRequest.setMirrors( getMirrors() );
             projectBuildingRequest.setActiveProfileIds( getActiveProfiles() );
             projectBuildingRequest.setInactiveProfileIds( getInactiveProfiles() );
             projectBuildingRequest.setProfiles( getProfiles() );

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Tue Sep  1 22:49:05 2009
@@ -85,7 +85,9 @@
                     try
                     {
                         ArtifactRepository repo = repositorySystem.buildArtifactRepository(
(Repository) repository );
-                        repos.addAll( repositorySystem.getMirrors( Arrays.asList( repo )
) );
+                        repositorySystem.injectMirror( Arrays.asList( repo ), configuration.getMirrors()
);
+                        repositorySystem.injectAuthentication( Arrays.asList( repo ), configuration.getServers()
);
+                        repos.add( repo );
                     }
                     catch ( InvalidRepositoryException e )
                     {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
Tue Sep  1 22:49:05 2009
@@ -114,7 +114,8 @@
         try
         {
             remoteRepositories =
-                projectBuildingHelper.createArtifactRepositories( model.getRepositories(),
remoteRepositories );
+                projectBuildingHelper.createArtifactRepositories( model.getRepositories(),
remoteRepositories,
+                                                                  projectBuildingRequest
);
         }
         catch ( Exception e )
         {
@@ -124,7 +125,8 @@
         try
         {
             pluginRepositories =
-                projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(),
pluginRepositories );
+                projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(),
pluginRepositories,
+                                                                  projectBuildingRequest
);
         }
         catch ( Exception e )
         {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
Tue Sep  1 22:49:05 2009
@@ -199,14 +199,8 @@
     private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration,
                                                           ReactorModelPool reactorModelPool
)
     {
-        RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
-        repositoryRequest.setCache( configuration.getRepositoryCache() );
-        repositoryRequest.setLocalRepository( configuration.getLocalRepository() );
-        repositoryRequest.setOffline( configuration.isOffline() );
-
         ModelResolver resolver =
-            new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
-                                         configuration.getRemoteRepositories(), reactorModelPool
);
+            new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration,
reactorModelPool );
 
         ModelBuildingRequest request = new DefaultModelBuildingRequest();
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
Tue Sep  1 22:49:05 2009
@@ -87,7 +87,8 @@
     private PluginVersionResolver pluginVersionResolver;
 
     public List<ArtifactRepository> createArtifactRepositories( List<Repository>
pomRepositories,
-                                                                List<ArtifactRepository>
externalRepositories )
+                                                                List<ArtifactRepository>
externalRepositories,
+                                                                ProjectBuildingRequest request
)
         throws InvalidRepositoryException
     {
         List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>();
@@ -97,7 +98,9 @@
             artifactRepositories.add( repositorySystem.buildArtifactRepository( repository
) );
         }
 
-        artifactRepositories = repositorySystem.getMirrors( artifactRepositories );
+        repositorySystem.injectMirror( artifactRepositories, request.getMirrors() );
+
+        repositorySystem.injectAuthentication( artifactRepositories, request.getServers()
);
 
         if ( externalRepositories != null )
         {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
Tue Sep  1 22:49:05 2009
@@ -29,6 +29,8 @@
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelEventListener;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Server;
 
 public class DefaultProjectBuildingRequest
     implements ProjectBuildingRequest
@@ -44,6 +46,10 @@
 
     private List<ArtifactRepository> pluginArtifactRepositories;
 
+    private List<Server> servers;
+
+    private List<Mirror> mirrors;
+
     private List<ModelEventListener> listeners;
 
     private MavenProject project;
@@ -79,6 +85,8 @@
         userProperties = new Properties();
         remoteRepositories = new ArrayList<ArtifactRepository>();
         pluginArtifactRepositories = new ArrayList<ArtifactRepository>();
+        servers = new ArrayList<Server>();
+        mirrors = new ArrayList<Mirror>();
     }
 
     public MavenProject getProject()
@@ -164,6 +172,44 @@
         return this;
     }
 
+    public ProjectBuildingRequest setServers( List<Server> servers )
+    {
+        if ( servers != null )
+        {
+            this.servers = new ArrayList<Server>( servers );
+        }
+        else
+        {
+            this.servers.clear();
+        }
+
+        return this;
+    }
+
+    public List<Server> getServers()
+    {
+        return servers;
+    }
+
+    public ProjectBuildingRequest setMirrors( List<Mirror> mirrors )
+    {
+        if ( mirrors != null )
+        {
+            this.mirrors = new ArrayList<Mirror>( mirrors );
+        }
+        else
+        {
+            this.mirrors.clear();
+        }
+
+        return this;
+    }
+
+    public List<Mirror> getMirrors()
+    {
+        return mirrors;
+    }
+
     public Properties getSystemProperties()
     {
         return systemProperties;

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Tue Sep  1 22:49:05 2009
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -1738,7 +1739,10 @@
         {           
             try
             {
-                setReleaseArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository()
) );
+                ArtifactRepository repo =
+                    repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository()
);
+                repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuilderConfiguration.getServers()
);
+                setReleaseArtifactRepository( repo );
             }
             catch ( InvalidRepositoryException e )
             {
@@ -1754,7 +1758,10 @@
         {           
             try
             {
-                setSnapshotArtifactRepository( repositorySystem.buildArtifactRepository(
getDistributionManagement().getSnapshotRepository() ) );
+                ArtifactRepository repo =
+                    repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository()
);
+                repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuilderConfiguration.getServers()
);
+                setSnapshotArtifactRepository( repo );
             }
             catch ( InvalidRepositoryException e )
             {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingHelper.java
Tue Sep  1 22:49:05 2009
@@ -46,11 +46,14 @@
      * @param pomRepositories The POM repositories to create the artifact repositories from,
must not be {@code null}.
      * @param externalRepositories The external (and already mirrored) repositories to merge
into the result list, may
      *            be {@code null}.
+     * @param request The project building request holding further settings like repository
settings, must not be
+     *            {@code null}.
      * @return The effective artifact repositories, never {@code null}.
      * @throws InvalidRepositoryException
      */
     List<ArtifactRepository> createArtifactRepositories( List<Repository> pomRepositories,
-                                                         List<ArtifactRepository> externalRepositories
)
+                                                         List<ArtifactRepository> externalRepositories,
+                                                         ProjectBuildingRequest request )
         throws InvalidRepositoryException;
 
     /**

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
Tue Sep  1 22:49:05 2009
@@ -27,6 +27,8 @@
 import org.apache.maven.artifact.repository.RepositoryCache;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Server;
 
 public interface ProjectBuildingRequest
 {
@@ -51,6 +53,14 @@
 
     List<ArtifactRepository> getPluginArtifactRepositories();
 
+    ProjectBuildingRequest setServers( List<Server> servers );
+
+    List<Server> getServers();
+
+    ProjectBuildingRequest setMirrors( List<Mirror> mirrors );
+
+    List<Mirror> getMirrors();
+
     /**
      * Sets the system properties to use for interpolation and profile activation. The system
properties are collected
      * from the runtime environment like {@link System#getProperties()} and environment variables.

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java
Tue Sep  1 22:49:05 2009
@@ -26,7 +26,6 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@@ -52,15 +51,14 @@
 
     private ResolutionErrorHandler resolutionErrorHandler;
 
-    private RepositoryRequest repositoryRequest;
+    private ProjectBuildingRequest projectBuildingRequest;
 
     private List<ArtifactRepository> remoteRepositories;
 
     private ReactorModelPool reactorModelPool;
 
     public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler
resolutionErrorHandler,
-                                    RepositoryRequest repositoryRequest, List<ArtifactRepository>
remoteRepositories,
-                                    ReactorModelPool reactorModelPool )
+                                    ProjectBuildingRequest projectBuildingRequest, ReactorModelPool
reactorModelPool )
     {
         if ( repositorySystem == null )
         {
@@ -74,25 +72,25 @@
         }
         this.resolutionErrorHandler = resolutionErrorHandler;
 
-        if ( repositoryRequest == null )
+        if ( projectBuildingRequest == null )
         {
-            throw new IllegalArgumentException( "no repository request specified" );
+            throw new IllegalArgumentException( "no project building request specified" );
         }
-        this.repositoryRequest = repositoryRequest;
+        this.projectBuildingRequest = projectBuildingRequest;
 
-        if ( remoteRepositories == null )
+        if ( projectBuildingRequest.getRemoteRepositories() == null )
         {
             throw new IllegalArgumentException( "no remote repositories specified" );
         }
-        this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories
);
+        this.remoteRepositories = new ArrayList<ArtifactRepository>( projectBuildingRequest.getRemoteRepositories()
);
 
         this.reactorModelPool = reactorModelPool;
     }
 
     public ModelResolver newCopy()
     {
-        return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
-                                            remoteRepositories, reactorModelPool );
+        return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, projectBuildingRequest,
+                                            reactorModelPool );
     }
 
     public void addRepository( Repository repository )
@@ -102,9 +100,11 @@
         {
             ArtifactRepository repo = repositorySystem.buildArtifactRepository( repository
);
 
-            List<ArtifactRepository> mirrors = repositorySystem.getMirrors( Arrays.asList(
repo ) );
+            repositorySystem.injectMirror( Arrays.asList( repo ), projectBuildingRequest.getMirrors()
);
 
-            remoteRepositories.addAll( 0, mirrors );
+            repositorySystem.injectAuthentication( Arrays.asList( repo ), projectBuildingRequest.getServers()
);
+
+            remoteRepositories.add( 0, repo );
 
             remoteRepositories = repositorySystem.getEffectiveRepositories( remoteRepositories
);
         }
@@ -128,9 +128,12 @@
         {
             Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId,
version );
 
-            ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest
);
+            ArtifactResolutionRequest request = new ArtifactResolutionRequest();
             request.setArtifact( artifactParent );
             request.setRemoteRepositories( remoteRepositories );
+            request.setLocalRepository( projectBuildingRequest.getLocalRepository() );
+            request.setOffline( projectBuildingRequest.isOffline() );
+            request.setCache( projectBuildingRequest.getRepositoryCache() );
             // FIXME setTransferListener
             ArtifactResolutionResult result = repositorySystem.resolve( request );
 

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java
(original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyProjectBuildingHelper.java
Tue Sep  1 22:49:05 2009
@@ -42,7 +42,8 @@
 {
 
     public List<ArtifactRepository> createArtifactRepositories( List<Repository>
pomRepositories,
-                                                                List<ArtifactRepository>
externalRepositories )
+                                                                List<ArtifactRepository>
externalRepositories,
+                                                                ProjectBuildingRequest request
)
         throws InvalidRepositoryException
     {
         if ( externalRepositories != null )

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=810296&r1=810295&r2=810296&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
Tue Sep  1 22:49:05 2009
@@ -229,17 +229,6 @@
             server.setPassword( password );
 
             request.addServer( server );
-
-            repositorySystem.addAuthenticationForArtifactRepository( server.getId(), server.getUsername(),
password );
-        }
-
-        for ( Mirror mirror : settings.getMirrors() )
-        {
-            mirror = mirror.clone();
-
-            request.addMirror( mirror );
-
-            repositorySystem.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl()
);
         }
 
         // <mirrors>
@@ -250,9 +239,22 @@
         //   </mirror>
         // </mirrors>        
 
-        request.setRemoteRepositories( repositorySystem.getMirrors( request.getRemoteRepositories()
) );
+        for ( Mirror mirror : settings.getMirrors() )
+        {
+            mirror = mirror.clone();
+
+            request.addMirror( mirror );
+        }
+
+        repositorySystem.injectMirror( request.getRemoteRepositories(), request.getMirrors()
);
+        repositorySystem.injectAuthentication( request.getRemoteRepositories(), request.getServers()
);
+
+        request.setRemoteRepositories( repositorySystem.getEffectiveRepositories( request.getRemoteRepositories()
) );
+
+        repositorySystem.injectMirror( request.getPluginArtifactRepositories(), request.getMirrors()
);
+        repositorySystem.injectAuthentication( request.getPluginArtifactRepositories(), request.getServers()
);
 
-        request.setPluginArtifactRepositories( repositorySystem.getMirrors( request.getPluginArtifactRepositories()
) );
+        request.setPluginArtifactRepositories( repositorySystem.getEffectiveRepositories(
request.getPluginArtifactRepositories() ) );
     }
 
     private String decrypt( String encrypted, String source )



Mime
View raw message