This commit is contained in:
Jason van Zyl 2009-02-25 18:28:39 +00:00
parent a882c1015b
commit f2d3908905
6 changed files with 56 additions and 68 deletions

View File

@ -138,7 +138,7 @@ public class DefaultPluginManager
protected PluginVersionManager pluginVersionManager;
@Requirement
protected MavenRepositorySystem repositoryTools;
protected MavenRepositorySystem repositorySystem;
@Requirement
protected RuntimeInformation runtimeInformation;
@ -393,7 +393,7 @@ public class DefaultPluginManager
try
{
projectPluginDependencies = repositoryTools.createArtifacts(
projectPluginDependencies = repositorySystem.createArtifacts(
plugin.getDependencies(),
null,
coreArtifactFilterManager.getCoreArtifactFilter(),
@ -409,7 +409,7 @@ public class DefaultPluginManager
try
{
resolutionGroup = repositoryTools.retrieve( pluginArtifact, localRepository, project.getRemoteArtifactRepositories() );
resolutionGroup = repositorySystem.retrieve( pluginArtifact, localRepository, project.getRemoteArtifactRepositories() );
}
catch ( ArtifactMetadataRetrievalException e )
{
@ -458,9 +458,9 @@ public class DefaultPluginManager
.setRemoteRepostories( repositories.isEmpty() ? Collections.EMPTY_LIST : new ArrayList( repositories ) )
.setManagedVersionMap( pluginManagedDependencies )
.setFilter( filter )
.setMetadataSource( repositoryTools );
.setMetadataSource( repositorySystem );
ArtifactResolutionResult result = repositoryTools.resolve( request );
ArtifactResolutionResult result = repositorySystem.resolve( request );
if ( result.hasErrorArtifactExceptions() )
{
@ -548,13 +548,13 @@ public class DefaultPluginManager
MavenProject p = (MavenProject) i.next();
resolveTransitiveDependencies( session,
repositoryTools,
repositorySystem,
mojoDescriptor.isDependencyResolutionRequired(),
p,
mojoDescriptor.isAggregator() );
}
downloadDependencies( project, session, repositoryTools );
downloadDependencies( project, session, repositorySystem );
}
String goalName = mojoDescriptor.getFullGoalName();

View File

@ -208,8 +208,8 @@ public class DefaultMavenExecutionRequestPopulator
profileManager.addProfile( profile );
// We need to convert profile repositories to artifact repositories
// We need to convert profile repositories to artifact repositories
for ( Iterator j = profile.getRepositories().iterator(); j.hasNext(); )
{
Repository r = (Repository) j.next();

View File

@ -31,6 +31,8 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.model.Build;
@ -194,7 +196,22 @@ public class DefaultMavenProjectBuilder
}
File f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
repositorySystem.findModelFromRepository( artifact, artifactRepositories, localRepository );
try
{
repositorySystem.findModelFromRepository( artifact, artifactRepositories, localRepository );
}
catch ( ArtifactResolutionException e )
{
throw new ProjectBuildingException( project.getId(), "Error resolving project artifact.", e );
}
catch ( ArtifactNotFoundException e )
{
throw new ProjectBuildingException( project.getId(), "Error finding project artifact.", e );
}
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( project.getId(), "Error with repository specified in project.", e );
}
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );

View File

@ -19,6 +19,14 @@ package org.apache.maven.project.artifact;
* under the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@ -41,27 +49,19 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Relocation;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.validation.ModelValidationResult;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.util.*;
/**
* @author Jason van Zyl
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
@ -70,7 +70,7 @@ import java.util.*;
@Component(role = ArtifactMetadataSource.class )
public class MavenMetadataSource
extends AbstractLogEnabled
implements ArtifactMetadataSource, Contextualizable
implements ArtifactMetadataSource
{
public static final String ROLE_HINT = "default";
@ -594,12 +594,6 @@ public class MavenMetadataSource
return versions;
}
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
private static final class ProjectRelocation
{
private MavenProject project;

View File

@ -53,7 +53,6 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
@ -128,7 +127,7 @@ public class LegacyMavenRepositorySystem
{
return null;
}
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope );
}
@ -143,7 +142,7 @@ public class LegacyMavenRepositorySystem
{
return null;
}
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
}
@ -160,8 +159,8 @@ public class LegacyMavenRepositorySystem
}
return artifactFactory.createExtensionArtifact( groupId, artifactId, versionRange );
}
}
public Artifact createParentArtifact( String groupId, String artifactId, String version )
{
return artifactFactory.createParentArtifact( groupId, artifactId, version );
@ -178,7 +177,7 @@ public class LegacyMavenRepositorySystem
{
return null;
}
return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange );
}
@ -348,7 +347,7 @@ public class LegacyMavenRepositorySystem
// Taken from RepositoryHelper
public void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
throws ProjectBuildingException
throws InvalidRepositoryException, ArtifactResolutionException, ArtifactNotFoundException
{
if ( cache.containsKey( artifact.getId() ) )
@ -374,26 +373,15 @@ public class LegacyMavenRepositorySystem
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope() );
}
try
{
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
File file = projectArtifact.getFile();
artifact.setFile( file );
cache.put( artifact.getId(), artifact );
}
catch ( ArtifactResolutionException e )
{
throw new ProjectBuildingException( projectId, "Error getting POM for '" + projectId + "' from the repository: " + e.getMessage(), e );
}
catch ( ArtifactNotFoundException e )
{
throw new ProjectBuildingException( projectId, "POM '" + projectId + "' not found in repository: " + e.getMessage(), e );
}
File file = projectArtifact.getFile();
artifact.setFile( file );
cache.put( artifact.getId(), artifact );
}
private List normalizeToArtifactRepositories( List remoteArtifactRepositories, String projectId )
throws ProjectBuildingException
throws InvalidRepositoryException
{
List normalized = new ArrayList( remoteArtifactRepositories.size() );
@ -409,21 +397,14 @@ public class LegacyMavenRepositorySystem
else if ( item instanceof Repository )
{
Repository repo = (Repository) item;
try
{
item = buildArtifactRepository( repo );
item = buildArtifactRepository( repo );
normalized.add( item );
normalizationNeeded = true;
}
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( projectId, "Error building artifact repository for id: " + repo.getId(), e );
}
normalized.add( item );
normalizationNeeded = true;
}
else
{
throw new ProjectBuildingException( projectId, "Error building artifact repository from non-repository information item: " + item );
throw new InvalidRepositoryException( projectId, "Error building artifact repository from non-repository information item: " + item );
}
}
@ -471,8 +452,8 @@ public class LegacyMavenRepositorySystem
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
return artifactResolver.resolve( request );
}
}
// ------------------------------------------------------------------------
// Extracted from DefaultWagonManager
// ------------------------------------------------------------------------

View File

@ -17,7 +17,6 @@ package org.apache.maven.repository;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@ -26,20 +25,15 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
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.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.wagon.events.TransferListener;
@ -93,6 +87,8 @@ public interface MavenRepositorySystem
// Artifact resolution
//MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
// This can be reduced to the request/result
@ -100,7 +96,7 @@ public interface MavenRepositorySystem
throws ArtifactResolutionException, ArtifactNotFoundException;
void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
throws ProjectBuildingException;
throws InvalidRepositoryException, ArtifactResolutionException, ArtifactNotFoundException;
// Version retrieval or metadata operations