maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r803059 [2/2] - in /maven/components/trunk: maven-compat/src/main/java/org/apache/maven/artifact/metadata/ maven-compat/src/main/java/org/apache/maven/artifact/repository/ maven-compat/src/main/java/org/apache/maven/artifact/repository/meta...
Date Tue, 11 Aug 2009 10:29:40 GMT
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Tue Aug 11 10:29:38 2009
@@ -32,6 +32,8 @@
 
 import org.apache.maven.ProjectDependenciesResolver;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.apache.maven.artifact.repository.metadata.RepositoryMetadataReadException;
 import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader;
@@ -154,6 +156,10 @@
 
         MavenExecutionResult result = session.getResult();
 
+        RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
+        repositoryRequest.setLocalRepository( session.getLocalRepository() );
+        repositoryRequest.setCache( session.getRepositoryCache() );
+
         for ( MavenProject currentProject : session.getProjects() )
         {
             if ( session.isBlackListed( currentProject ) )
@@ -185,7 +191,8 @@
                 // the project dependencies. Having it happen in the plugin manager is a
tangled mess. We can optimize this
                 // later by looking at the build plan. Would be better to just batch download
everything required by the reactor.
 
-                projectDependenciesResolver.resolve( currentProject, executionPlan.getRequiredResolutionScopes(),
session.getLocalRepository(), currentProject.getRemoteArtifactRepositories() );
+                repositoryRequest.setRemoteRepositories( currentProject.getRemoteArtifactRepositories()
);
+                projectDependenciesResolver.resolve( currentProject, executionPlan.getRequiredResolutionScopes(),
repositoryRequest );
 
                 if ( logger.isDebugEnabled() )
                 {
@@ -330,8 +337,7 @@
             {
                 mojoDescriptor =
                     pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
-                                                     session.getLocalRepository(),
-                                                     project.getPluginArtifactRepositories()
);
+                                                     getRepositoryRequest( session, project
) );
 
                 mojoExecution.setMojoDescriptor( mojoDescriptor );
             }
@@ -354,6 +360,16 @@
 
         return new MavenExecutionPlan( lifecyclePlan, requiredDependencyResolutionScopes
);
     }      
+    private RepositoryRequest getRepositoryRequest( MavenSession session, MavenProject project
)
+    {
+        RepositoryRequest request = new DefaultRepositoryRequest();
+
+        request.setCache( session.getRepositoryCache() );
+        request.setLocalRepository( session.getLocalRepository() );
+        request.setRemoteRepositories( project.getPluginArtifactRepositories() );
+
+        return request;
+    }
 
     private void collectDependencyResolutionScopes( Collection<String> requiredDependencyResolutionScopes,
                                                     MojoExecution mojoExecution )
@@ -511,8 +527,7 @@
                     for ( String goal : execution.getGoals() )
                     {
                         MojoDescriptor mojoDescriptor =
-                            pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(),
-                                                             project.getPluginArtifactRepositories()
);
+                            pluginManager.getMojoDescriptor( plugin, goal, getRepositoryRequest(
session, project ) );
 
                         List<MojoExecution> mojoExecutions = lifecycleMappings.get(
mojoDescriptor.getPhase() );
                         if ( mojoExecutions != null )
@@ -557,8 +572,7 @@
                     {
                         MojoDescriptor forkedMojoDescriptor =
                             pluginManager.getMojoDescriptor( forkedExecution.getPlugin(),
forkedExecution.getGoal(),
-                                                             session.getLocalRepository(),
-                                                             project.getPluginArtifactRepositories()
);
+                                                             getRepositoryRequest( session,
project ) );
 
                         forkedExecution.setMojoDescriptor( forkedMojoDescriptor );
                     }
@@ -875,20 +889,24 @@
 
         injectPluginDeclarationFromProject( plugin, project );
 
+        RepositoryRequest repositoryRequest = getRepositoryRequest( session, project );
+
         // If there is no version to be found then we need to look in the repository metadata
for
         // this plugin and see what's specified as the latest release.
         //
         if ( plugin.getVersion() == null )
         {
-            resolvePluginVersion( plugin, session.getLocalRepository(), project.getPluginArtifactRepositories()
);
+            resolvePluginVersion( plugin, repositoryRequest );
         }
-        
-        return pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(),
project.getPluginArtifactRepositories() );
+
+        return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
     }
 
-    private void resolvePluginVersion( Plugin plugin, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
+    private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest
)
         throws PluginNotFoundException
     {
+        ArtifactRepository localRepository = repositoryRequest.getLocalRepository();
+
         File artifactMetadataFile = null;
         
         String localPath; 
@@ -899,7 +917,7 @@
         //
         //TODO: we should cycle through the repositories but take the repository which actually
         // satisfied the prefix.
-        for ( ArtifactRepository repository : remoteRepositories )
+        for ( ArtifactRepository repository : repositoryRequest.getRemoteRepositories() )
         {
             localPath = plugin.getGroupId().replace( '.', '/' ) + "/" + plugin.getArtifactId()
+ "/maven-metadata-" + repository.getId() + ".xml";
 
@@ -974,7 +992,7 @@
 
         if ( StringUtils.isEmpty( plugin.getVersion() ) )
         {
-            throw new PluginNotFoundException( plugin, remoteRepositories );
+            throw new PluginNotFoundException( plugin, repositoryRequest.getRemoteRepositories()
);
         }
     }
 
@@ -1125,14 +1143,14 @@
         }
     }
     
-    private void populateDefaultConfigurationForPlugin( Plugin plugin, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories ) 
+    private void populateDefaultConfigurationForPlugin( Plugin plugin, RepositoryRequest
repositoryRequest ) 
         throws LifecycleExecutionException
     {
         if ( plugin.getVersion() == null )
         {
             try
             {
-                resolvePluginVersion( plugin, localRepository, remoteRepositories );
+                resolvePluginVersion( plugin, repositoryRequest );
             }
             catch ( PluginNotFoundException e )
             {
@@ -1144,29 +1162,29 @@
         {
             for( String goal : pluginExecution.getGoals() )
             {
-                Xpp3Dom dom = getDefaultPluginConfiguration( plugin, goal, localRepository,
remoteRepositories );
+                Xpp3Dom dom = getDefaultPluginConfiguration( plugin, goal, repositoryRequest
);
                 pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(),
dom, Boolean.TRUE ) );
             }
         }
     }
     
-    public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories ) 
+    public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins,
RepositoryRequest repositoryRequest ) 
         throws LifecycleExecutionException
     {
         for( Plugin plugin : plugins )
         {            
-            populateDefaultConfigurationForPlugin( plugin, localRepository, remoteRepositories
);
+            populateDefaultConfigurationForPlugin( plugin, repositoryRequest );
         }
     }    
     
-    private Xpp3Dom getDefaultPluginConfiguration( Plugin plugin, String goal, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories ) 
+    private Xpp3Dom getDefaultPluginConfiguration( Plugin plugin, String goal, RepositoryRequest
repositoryRequest ) 
         throws LifecycleExecutionException
     {
         MojoDescriptor mojoDescriptor;
         
         try
         {
-            mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, localRepository,
remoteRepositories );
+            mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest
);
         }
         catch ( PluginNotFoundException e )
         {
@@ -1252,13 +1270,13 @@
 
         if ( project != null )
         {
+            RepositoryRequest repositoryRequest = getRepositoryRequest( session, project
);
+
             for ( Plugin buildPlugin : project.getBuildPlugins() )
             {
                 try
                 {
-                    PluginDescriptor pluginDescriptor =
-                        pluginManager.loadPlugin( buildPlugin, session.getLocalRepository(),
-                                                  project.getPluginArtifactRepositories()
);
+                    PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( buildPlugin,
repositoryRequest );
 
                     if ( prefix.equals( pluginDescriptor.getGoalPrefix() ) )
                     {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java
Tue Aug 11 10:29:38 2009
@@ -24,6 +24,7 @@
 import java.util.Set;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
@@ -72,7 +73,7 @@
     // Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can
lookup the plugin
     // descriptor and populate the default configuration.
     //
-    void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories )
+    void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, RepositoryRequest
repositoryRequest )
         throws LifecycleExecutionException;
     
     void execute( MavenSession session );

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
Tue Aug 11 10:29:38 2009
@@ -34,6 +34,8 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
@@ -106,8 +108,7 @@
     /**
      * 
      * @param plugin
-     * @param localRepository
-     * @param remoteRepositories
+     * @param repositoryRequest
      * @return PluginDescriptor The component descriptor for the Maven plugin.
      * @throws PluginNotFoundException The plugin could not be found in any repositories.
      * @throws PluginResolutionException The plugin could be found but could not be resolved.
@@ -116,10 +117,12 @@
      *                                      happen but if someone has made a descriptor by
hand it's possible.
      * @throws CycleDetectedInComponentGraphException A cycle has been detected in the component
graph for a plugin that has been dynamically loaded.
      */
-    public synchronized PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
+    public synchronized PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest
)
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, InvalidPluginDescriptorException
     {
-        PluginDescriptor pluginDescriptor = pluginCache.getPluginDescriptor( plugin, localRepository,
remoteRepositories );
+        PluginDescriptor pluginDescriptor =
+            pluginCache.getPluginDescriptor( plugin, repositoryRequest.getLocalRepository(),
+                                             repositoryRequest.getRemoteRepositories() );
         
         if ( pluginDescriptor != null )
         {
@@ -128,10 +131,8 @@
 
         Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
 
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest()
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest
)
             .setArtifact( pluginArtifact )
-            .setLocalRepository( localRepository )
-            .setRemoteRepositories( remoteRepositories )
             .setResolveTransitively( false );
         // FIXME setTransferListener
         ArtifactResolutionResult result = repositorySystem.resolve( request );
@@ -207,7 +208,8 @@
             pluginDescriptor.setPlugin( plugin );
             pluginDescriptor.setPluginArtifact( pluginArtifact );
 
-            pluginCache.putPluginDescriptor( plugin, localRepository, remoteRepositories,
pluginDescriptor );
+            pluginCache.putPluginDescriptor( plugin, repositoryRequest.getLocalRepository(),
+                                             repositoryRequest.getRemoteRepositories(), pluginDescriptor
);
 
             return pluginDescriptor;
         
@@ -242,7 +244,7 @@
      * no file set is meant to be excluded from the plugin realm in favor of the equivalent
library from the current
      * core distro.
      */
-    List<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedInPom,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
+    List<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin pluginAsSpecifiedInPom,
RepositoryRequest repositoryRequest )
         throws ArtifactNotFoundException, ArtifactResolutionException
     {
         ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME_PLUS_SYSTEM
);
@@ -269,12 +271,10 @@
             dependenciesToResolveForPlugin.add( a );                            
         }
         
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest()
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest
)
             .setArtifact( pluginArtifact )
             // So this in fact are overrides ... 
             .setArtifactDependencies( dependenciesToResolveForPlugin )
-            .setLocalRepository( localRepository )
-            .setRemoteRepositories( remoteRepositories )
             .setFilter( filter )
             .setResolveRoot( true )
             .setResolveTransitively( true );
@@ -396,6 +396,7 @@
         }
 
         Plugin plugin = pluginDescriptor.getPlugin();
+        
         ArtifactRepository localRepository = session.getLocalRepository();
         List<ArtifactRepository> remoteRepositories = session.getCurrentProject().getPluginArtifactRepositories();
 
@@ -417,7 +418,11 @@
 
         try
         {
-            pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, localRepository,
remoteRepositories );
+            RepositoryRequest request = new DefaultRepositoryRequest();
+            request.setLocalRepository( localRepository );
+            request.setRemoteRepositories( remoteRepositories );
+            request.setCache( session.getRepositoryCache() );
+            pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, request );
         }
         catch ( ArtifactNotFoundException e )
         {
@@ -686,7 +691,7 @@
         }
     }
 
-    public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version,
String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories
)
+    public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version,
String goal, RepositoryRequest repositoryRequest )
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
     {
         Plugin plugin = new Plugin();
@@ -694,13 +699,13 @@
         plugin.setArtifactId( artifactId );
         plugin.setVersion( version );
         
-        return getMojoDescriptor( plugin, goal, localRepository, remoteRepositories );
+        return getMojoDescriptor( plugin, goal, repositoryRequest );
     }
         
-    public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories )
+    public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest
repositoryRequest )
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
     {
-        PluginDescriptor pluginDescriptor = loadPlugin( plugin, localRepository, remoteRepositories
);
+        PluginDescriptor pluginDescriptor = loadPlugin( plugin, repositoryRequest );
 
         MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
 

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
Tue Aug 11 10:29:38 2009
@@ -15,9 +15,7 @@
  * the License.
  */
 
-import java.util.List;
-
-import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -30,15 +28,15 @@
 public interface PluginManager
 {
     // igorf: Way too many declared exceptions!
-    PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository>
remoteRepositories )
+    PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, InvalidPluginDescriptorException;
 
     // igorf: Way too many declared exceptions!
-    MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version,
String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories
)
+    MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version,
String goal, RepositoryRequest repositoryRequest )
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
 
     // igorf: Way too many declared exceptions!
-    MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
+    MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest
)
         throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
 
     void executeMojo( MavenSession session, MojoExecution execution )

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=803059&r1=803058&r2=803059&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 Aug 11 10:29:38 2009
@@ -24,6 +24,8 @@
 import org.apache.maven.Maven;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+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;
@@ -162,8 +164,12 @@
     private ModelBuildingRequest getModelBuildingRequest( ProjectBuildingRequest configuration,
                                                           ReactorModelPool reactorModelPool
)
     {
+        RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
+        repositoryRequest.setCache( configuration.getRepositoryCache() );
+        repositoryRequest.setLocalRepository( configuration.getLocalRepository() );
+
         ModelResolver resolver =
-            new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration.getLocalRepository(),
+            new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
                                          configuration.getRemoteRepositories(), reactorModelPool
);
 
         ModelBuildingRequest request = new DefaultModelBuildingRequest();
@@ -191,6 +197,7 @@
 
         ArtifactResolutionRequest request = new ArtifactResolutionRequest()
             .setArtifact( artifact )
+            .setCache( configuration.getRepositoryCache() )
             .setLocalRepository( configuration.getLocalRepository() )
             .setRemoteRepositories( configuration.getRemoteRepositories() );
         // FIXME setTransferListener
@@ -257,6 +264,7 @@
             .setArtifact( artifact )
             .setResolveRoot( false )
             .setResolveTransitively( true )
+            .setCache( request.getRepositoryCache() )
             .setLocalRepository( request.getLocalRepository() )
             .setRemoteRepositories( project.getRemoteArtifactRepositories() )
             .setManagedVersionMap( project.getManagedVersionMap() );
@@ -492,9 +500,12 @@
         {
             if ( configuration.isProcessPlugins() )
             {
-                lifecycle.populateDefaultConfigurationForPlugins( model.getBuild().getPlugins(),
-                                                                  configuration.getLocalRepository(),
-                                                                  project.getPluginArtifactRepositories()
);
+                RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
+                repositoryRequest.setLocalRepository( configuration.getLocalRepository()
);
+                repositoryRequest.setRemoteRepositories( project.getPluginArtifactRepositories()
);
+                repositoryRequest.setCache( configuration.getRepositoryCache() );
+
+                lifecycle.populateDefaultConfigurationForPlugins( model.getBuild().getPlugins(),
repositoryRequest );
             }
         }
         catch ( LifecycleExecutionException e )

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=803059&r1=803058&r2=803059&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 Aug 11 10:29:38 2009
@@ -25,6 +25,7 @@
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryCache;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelEventListener;
@@ -32,6 +33,9 @@
 public class DefaultProjectBuildingRequest
     implements ProjectBuildingRequest
 {
+
+    private RepositoryCache repositoryCache;
+
     private ArtifactRepository localRepository;
 
     private List<ArtifactRepository> remoteRepositories;
@@ -80,6 +84,18 @@
         this.topProject = mavenProject;
     }
 
+    public ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache )
+    {
+        this.repositoryCache = repositoryCache;
+
+        return this;
+    }
+
+    public RepositoryCache getRepositoryCache()
+    {
+        return repositoryCache;
+    }
+
     public ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository
)
     {
         this.localRepository = localRepository;

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=803059&r1=803058&r2=803059&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 Aug 11 10:29:38 2009
@@ -25,12 +25,18 @@
 
 import org.apache.maven.MavenTransferListener;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryCache;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.wagon.events.TransferListener;
 
 public interface ProjectBuildingRequest
 {
+
+    ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache );
+
+    RepositoryCache getRepositoryCache();
+
     ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository );
     
     ArtifactRepository getLocalRepository();

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=803059&r1=803058&r2=803059&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 Aug 11 10:29:38 2009
@@ -26,6 +26,7 @@
 
 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;
@@ -51,14 +52,14 @@
 
     private ResolutionErrorHandler resolutionErrorHandler;
 
-    private ArtifactRepository localRepository;
+    private RepositoryRequest repositoryRequest;
 
     private List<ArtifactRepository> remoteRepositories;
 
     private ReactorModelPool reactorModelPool;
 
     public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler
resolutionErrorHandler,
-                                    ArtifactRepository localRepository, List<ArtifactRepository>
remoteRepositories,
+                                    RepositoryRequest repositoryRequest, List<ArtifactRepository>
remoteRepositories,
                                     ReactorModelPool reactorModelPool )
     {
         if ( repositorySystem == null )
@@ -73,11 +74,11 @@
         }
         this.resolutionErrorHandler = resolutionErrorHandler;
 
-        if ( localRepository == null )
+        if ( repositoryRequest == null )
         {
-            throw new IllegalArgumentException( "no local repository specified" );
+            throw new IllegalArgumentException( "no repository request specified" );
         }
-        this.localRepository = localRepository;
+        this.repositoryRequest = repositoryRequest;
 
         if ( remoteRepositories == null )
         {
@@ -90,7 +91,7 @@
 
     public ModelResolver newCopy()
     {
-        return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, localRepository,
+        return new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, repositoryRequest,
                                             remoteRepositories, reactorModelPool );
     }
 
@@ -127,9 +128,8 @@
         {
             Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId,
version );
 
-            ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+            ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest
);
             request.setArtifact( artifactParent );
-            request.setLocalRepository( localRepository );
             request.setRemoteRepositories( remoteRepositories );
             // FIXME setTransferListener
             ArtifactResolutionResult result = repositorySystem.resolve( request );

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
Tue Aug 11 10:29:38 2009
@@ -32,6 +32,7 @@
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.metadata.ResolutionGroup;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
 import org.apache.maven.artifact.repository.metadata.Metadata;
 import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
@@ -55,6 +56,7 @@
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
 import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.annotations.Component;
@@ -88,13 +90,6 @@
     @Requirement
     private MavenMetadataCache cache;    
 
-    public ResolutionGroup retrieve( MetadataResolutionRequest request )
-        throws ArtifactMetadataRetrievalException
-    {
-        return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories(),
-                         request.isResolveManagedVersions() );
-    }
-
     public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
                                      List<ArtifactRepository> remoteRepositories )
         throws ArtifactMetadataRetrievalException
@@ -106,6 +101,19 @@
                                      List<ArtifactRepository> remoteRepositories, boolean
resolveManagedVersions )
         throws ArtifactMetadataRetrievalException
     {
+        MetadataResolutionRequest request = new DefaultMetadataResolutionRequest();
+        request.setArtifact( artifact );
+        request.setLocalRepository( localRepository );
+        request.setRemoteRepositories( remoteRepositories );
+        request.setResolveManagedVersions( resolveManagedVersions );
+        return retrieve( request );
+    }
+
+    public ResolutionGroup retrieve( MetadataResolutionRequest request )
+        throws ArtifactMetadataRetrievalException
+    {
+        Artifact artifact = request.getArtifact();
+
         //
         // If we have a system scoped artifact then we do not want any searching in local
or remote repositories
         // and we want artifact resolution to only return the system scoped artifact itself.
@@ -114,8 +122,10 @@
         {
             return new ResolutionGroup( null, null, null );
         }
-        
-        ResolutionGroup cached = cache.get( artifact, resolveManagedVersions, localRepository,
remoteRepositories );
+
+        ResolutionGroup cached =
+            cache.get( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
+                       request.getRemoteRepositories() );
 
         if ( cached != null )
         {
@@ -142,7 +152,7 @@
         }
         else
         {
-            ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository,
remoteRepositories );
+            ProjectRelocation rel = retrieveRelocatedProject( artifact, request );
             
             if ( rel == null )
             {
@@ -188,7 +198,7 @@
 
         Map<String, Artifact> managedVersions = null;
 
-        if ( managedDependencies != null && resolveManagedVersions )
+        if ( managedDependencies != null && request.isResolveManagedVersions() )
         {
             managedVersions = new HashMap<String, Artifact>();
 
@@ -201,9 +211,10 @@
         }
 
         ResolutionGroup result =
-            new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions,
remoteRepositories );
+            new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions,
request.getRemoteRepositories() );
 
-        cache.put( artifact, resolveManagedVersions, localRepository, remoteRepositories,
result );
+        cache.put( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
+                   request.getRemoteRepositories(), result );
 
         return result;
     }
@@ -319,15 +330,25 @@
     public List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository
localRepository, List<ArtifactRepository> remoteRepositories )
         throws ArtifactMetadataRetrievalException
     {
-        RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
+        MetadataResolutionRequest request = new DefaultMetadataResolutionRequest();
+        request.setArtifact( artifact );
+        request.setLocalRepository( localRepository );
+        request.setRemoteRepositories( remoteRepositories );
+        return retrieveAvailableVersions( request );
+    }
+
+    public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest
request )
+        throws ArtifactMetadataRetrievalException
+    {
+        RepositoryMetadata metadata = new ArtifactRepositoryMetadata( request.getArtifact()
);
 
         try
         {
-            repositoryMetadataManager.resolve( metadata, remoteRepositories, localRepository
);
+            repositoryMetadataManager.resolve( metadata, request );
         }
         catch ( RepositoryMetadataResolutionException e )
         {
-            throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
+            throw new ArtifactMetadataRetrievalException( e.getMessage(), e, request.getArtifact()
);
         }
 
         return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
@@ -416,8 +437,7 @@
         return projectBuilder;
     }
 
-    private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository
localRepository,
-                                                        List<ArtifactRepository> remoteRepositories
)
+    private ProjectRelocation retrieveRelocatedProject( Artifact artifact, RepositoryRequest
repositoryRequest )
         throws ArtifactMetadataRetrievalException
     {
         MavenProject project = null;
@@ -446,8 +466,9 @@
                 try
                 {
                     ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
-                    configuration.setLocalRepository( localRepository );
-                    configuration.setRemoteRepositories( remoteRepositories );
+                    configuration.setRepositoryCache( repositoryRequest.getCache() );
+                    configuration.setLocalRepository( repositoryRequest.getLocalRepository()
);
+                    configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories()
);
                     configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL
);
                     configuration.setProcessPlugins( false );
                     configuration.setSystemProperties( System.getProperties() );
@@ -509,8 +530,10 @@
                         List<ArtifactVersion> available = artifact.getAvailableVersions();
                         if ( available != null && !available.isEmpty() )
                         {
-                            available =
-                                retrieveAvailableVersions( relocatedArtifact, localRepository,
remoteRepositories );
+                            MetadataResolutionRequest metadataRequest =
+                                new DefaultMetadataResolutionRequest( repositoryRequest );
+                            metadataRequest.setArtifact( relocatedArtifact );
+                            available = retrieveAvailableVersions( metadataRequest );
                             relocatedArtifact.setAvailableVersions( available );
                         }
 

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
(original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/ProjectDependenciesResolverTest.java
Tue Aug 11 10:29:38 2009
@@ -7,6 +7,9 @@
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Exclusion;
 import org.apache.maven.project.MavenProject;
@@ -38,6 +41,15 @@
         return "src/test/projects/project-dependencies-resolver";
     }
 
+    protected RepositoryRequest getRepositoryRequest()
+        throws InvalidRepositoryException
+    {
+        RepositoryRequest request = new DefaultRepositoryRequest();
+        request.setLocalRepository( getLocalRepository() );
+        request.setRemoteRepositories( getRemoteRepositories() );
+        return request;
+    }
+
     public void testExclusionsInDependencies()
         throws Exception
     {
@@ -50,13 +62,11 @@
             .get();        
         
         Set<Artifact> artifactDependencies =
-            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
-                              getRemoteRepositories() );
+            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest()
);
         assertEquals( 0, artifactDependencies.size() );
         
         artifactDependencies =
-            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), getLocalRepository(),
-                              getRemoteRepositories() );
+            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_RUNTIME ), getRepositoryRequest()
);
         assertEquals( 1, artifactDependencies.size() );
         assertEquals( "maven-core-it-support" , artifactDependencies.iterator().next().getArtifactId()
);
     }
@@ -69,8 +79,7 @@
             .get();
 
         Set<Artifact> artifactDependencies =
-            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
-                              getRemoteRepositories() );                
+            resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest()
);                
         assertEquals( 1, artifactDependencies.size() );        
     }  
     
@@ -85,8 +94,7 @@
         MavenSession session = createMavenSession( pom, eps );
         MavenProject project = session.getCurrentProject();
 
-        resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getLocalRepository(),
-                          getRemoteRepositories() );                
+        resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), getRepositoryRequest()
);                
                 
         List<String> elements = project.getCompileClasspathElements();
         assertEquals( 2, elements.size() );

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
(original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginManagerTest.java
Tue Aug 11 10:29:38 2009
@@ -4,6 +4,8 @@
 
 import org.apache.maven.AbstractCoreMavenComponentTestCase;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -38,7 +40,17 @@
     {
         return "src/test/projects/plugin-manager";
     }
-                
+
+    private RepositoryRequest getRepositoryRequest( MavenSession session )
+    {
+        RepositoryRequest request = new DefaultRepositoryRequest();
+
+        request.setLocalRepository( session.getLocalRepository() );
+        request.setRemoteRepositories( session.getCurrentProject().getPluginArtifactRepositories()
);
+
+        return request;
+    }
+
     public void testPluginLoading()
         throws Exception
     {
@@ -47,7 +59,7 @@
         plugin.setGroupId( "org.codehaus.plexus" );
         plugin.setArtifactId( "plexus-component-metadata" );
         plugin.setVersion( plexusVersion );
-        PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, session.getLocalRepository(),
session.getCurrentProject().getPluginArtifactRepositories() );
+        PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, getRepositoryRequest(
session ) );
         assertNotNull( pluginDescriptor );
     }
     
@@ -61,7 +73,7 @@
         plugin.setArtifactId( "plexus-component-metadata" );
         plugin.setVersion( plexusVersion );
         
-        MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, session.getLocalRepository(),
session.getCurrentProject().getPluginArtifactRepositories() );        
+        MojoDescriptor mojoDescriptor = pluginManager.getMojoDescriptor( plugin, goal, getRepositoryRequest(
session ) );        
         assertNotNull( mojoDescriptor );
         assertEquals( "generate-metadata", mojoDescriptor.getGoal() );
         // igorf: plugin realm comes later
@@ -225,7 +237,11 @@
         ArtifactResolutionResult result = repositorySystem.resolve( request );
         */
         
-        List<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact,
plugin, getLocalRepository(), getPluginArtifactRepositories() );   
+        RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
+        repositoryRequest.setLocalRepository( getLocalRepository() );
+        repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() );
+        
+        List<Artifact> artifacts = pluginManager.getPluginArtifacts( pluginArtifact,
plugin, repositoryRequest );   
         
         for ( Artifact a : artifacts )
         {

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java?rev=803059&r1=803058&r2=803059&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
(original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/EmptyLifecycleExecutor.java
Tue Aug 11 10:29:38 2009
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.lifecycle.LifecycleExecutionException;
 import org.apache.maven.lifecycle.LifecycleExecutor;
@@ -75,7 +76,7 @@
         return Collections.emptySet();
     }
 
-    public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
+    public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins,
RepositoryRequest repositoryRequest )
         throws LifecycleExecutionException
     {
     }



Mime
View raw message