o Fixed project building helper to use repo cache

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@803256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-11 19:32:27 +00:00
parent 13709defd0
commit 91d459309f
4 changed files with 20 additions and 17 deletions

View File

@ -22,6 +22,8 @@ package org.apache.maven.project;
import java.util.List;
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.ArtifactResolutionException;
import org.apache.maven.model.Model;
import org.apache.maven.model.building.AbstractModelBuildingListener;
@ -132,9 +134,13 @@ class DefaultModelBuildingListener
{
try
{
projectRealm =
projectBuildingHelper.createProjectRealm( model, projectBuildingRequest.getLocalRepository(),
pluginRepositories );
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
repositoryRequest.setCache( projectBuildingRequest.getRepositoryCache() );
repositoryRequest.setLocalRepository( projectBuildingRequest.getLocalRepository() );
repositoryRequest.setRemoteRepositories( pluginRepositories );
repositoryRequest.setOffline( projectBuildingRequest.isOffline() );
projectRealm = projectBuildingHelper.createProjectRealm( model, repositoryRequest );
}
catch ( ArtifactResolutionException e )
{

View File

@ -29,6 +29,7 @@ import org.apache.maven.ArtifactFilterManager;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
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;
@ -101,8 +102,7 @@ public class DefaultProjectBuildingHelper
return artifactRepositories;
}
public ClassRealm createProjectRealm( Model model, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
throws ArtifactResolutionException
{
ClassRealm projectRealm = null;
@ -137,7 +137,7 @@ public class DefaultProjectBuildingHelper
repositorySystem.createArtifact( extension.getGroupId(), extension.getArtifactId(),
extension.getVersion(), "jar" );
populateRealm( projectRealm, artifact, null, localRepository, remoteRepositories );
populateRealm( projectRealm, artifact, null, repositoryRequest );
}
for ( Plugin plugin : extensionPlugins )
@ -150,7 +150,7 @@ public class DefaultProjectBuildingHelper
dependencies.add( repositorySystem.createDependencyArtifact( dependency ) );
}
populateRealm( projectRealm, artifact, dependencies, localRepository, remoteRepositories );
populateRealm( projectRealm, artifact, dependencies, repositoryRequest );
}
try
@ -167,15 +167,13 @@ public class DefaultProjectBuildingHelper
}
private void populateRealm( ClassRealm realm, Artifact artifact, Set<Artifact> dependencies,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
RepositoryRequest repositoryRequest )
throws ArtifactResolutionException
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
ArtifactResolutionRequest request = new ArtifactResolutionRequest( repositoryRequest );
request.setArtifact( artifact );
request.setArtifactDependencies( dependencies );
request.setResolveTransitively( true );
request.setLocalRepository( localRepository );
request.setRemoteRepositories( remoteRepositories );
// FIXME setTransferListener
ArtifactResolutionResult result = repositorySystem.resolve( request );

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.maven.artifact.InvalidRepositoryException;
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.model.Model;
import org.apache.maven.model.Repository;
@ -55,13 +56,11 @@ public interface ProjectBuildingHelper
* Creates the project realm that hosts the build extensions of the specified model.
*
* @param model The model to create the project realm for, must not be {@code null}
* @param localRepository The local repository to use for artifact resolution, must not be {@code null}.
* @param remoteRepositories The remote repositories to use for artifact resolution, must not be {@code null}.
* @param repositoryRequest The repository request to use for artifact resolution, must not be {@code null}.
* @return The project realm or {@code null} if the project uses no extensions.
* @throws ArtifactResolutionException If any build extension could not be resolved.
*/
ClassRealm createProjectRealm( Model model, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
throws ArtifactResolutionException;
}

View File

@ -24,6 +24,7 @@ import java.util.List;
import org.apache.maven.artifact.InvalidRepositoryException;
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.model.Model;
import org.apache.maven.model.Repository;
@ -54,8 +55,7 @@ public class EmptyProjectBuildingHelper
}
}
public ClassRealm createProjectRealm( Model model, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
public ClassRealm createProjectRealm( Model model, RepositoryRequest repositoryRequest )
throws ArtifactResolutionException
{
return null;