o checking in so that oleg and shane can see the changes, there are three failing tests. i'm fixing in the plane and will check in when i land

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@746850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-02-23 00:04:14 +00:00
parent 63c695adaa
commit 00c302e021
20 changed files with 321 additions and 621 deletions

View File

@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.maven.ArtifactFilterManager;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@ -78,6 +77,7 @@ import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.realm.MavenRealmManager;
import org.apache.maven.realm.RealmManagementException;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.repository.MavenRepositorySystem;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.apache.maven.shared.model.ModelMarshaller;
import org.apache.maven.shared.model.ModelProperty;
@ -137,7 +137,7 @@ public class DefaultPluginManager
protected PluginVersionManager pluginVersionManager;
@Requirement
protected RepositorySystem repositoryTools;
protected MavenRepositorySystem repositoryTools;
@Requirement
protected RuntimeInformation runtimeInformation;
@ -1471,7 +1471,7 @@ public class DefaultPluginManager
// ----------------------------------------------------------------------
protected void resolveTransitiveDependencies( MavenSession context,
RepositorySystem repositoryTools,
MavenRepositorySystem repositoryTools,
String scope,
MavenProject project,
boolean isAggregator )
@ -1582,7 +1582,7 @@ public class DefaultPluginManager
private void downloadDependencies( MavenProject project,
MavenSession context,
RepositorySystem repositoryTools )
MavenRepositorySystem repositoryTools )
throws ArtifactResolutionException, ArtifactNotFoundException
{
ArtifactRepository localRepository = context.getLocalRepository();

View File

@ -22,7 +22,6 @@ package org.apache.maven.plugin.version;
import java.util.Iterator;
import java.util.List;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@ -40,6 +39,7 @@ import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled;
@ -51,7 +51,7 @@ public class DefaultPluginVersionManager
implements PluginVersionManager
{
@Requirement
private RepositorySystem repositoryTools;
private MavenRepositorySystem repositoryTools;
@Requirement
private MavenProjectBuilder mavenProjectBuilder;

View File

@ -31,7 +31,6 @@ import java.util.Iterator;
import java.util.List;
import org.apache.maven.Maven;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@ -73,6 +72,7 @@ import org.apache.maven.project.MavenProjectBuildingResult;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
import org.apache.maven.reactor.MissingModuleException;
import org.apache.maven.repository.MavenRepositorySystem;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.SettingsConfigurationException;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
@ -137,7 +137,7 @@ public class MavenEmbedder
private MavenXpp3Writer modelWriter;
private RepositorySystem repositoryTools;
private MavenRepositorySystem repositoryTools;
private Maven maven;
@ -659,7 +659,7 @@ public class MavenEmbedder
pluginRepository = container.lookup( PluginRepository.class );
repositoryTools = container.lookup( RepositorySystem.class );
repositoryTools = container.lookup( MavenRepositorySystem.class );
// This is temporary as we can probably cache a single request and use it for default values and
// simply cascade values in from requests used for individual executions.

View File

@ -26,7 +26,6 @@ import java.util.List;
import java.util.Properties;
import org.apache.maven.Maven;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@ -44,6 +43,7 @@ import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.realm.DefaultMavenRealmManager;
import org.apache.maven.repository.MavenRepositorySystem;
import org.apache.maven.settings.MavenSettingsBuilder;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy;
@ -86,7 +86,7 @@ public class DefaultMavenExecutionRequestPopulator
private MavenSettingsBuilder settingsBuilder;
@Requirement
private RepositorySystem mavenTools;
private MavenRepositorySystem mavenTools;
// 2009-02-12 Oleg: this component is defined in maven-core components.xml
// because it already has another declared (not generated) component

View File

@ -1,140 +0,0 @@
package org.apache.maven;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
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.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ResolutionListener;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
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;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* @author Jason van Zyl
*/
public interface RepositorySystem
{
List<ArtifactRepository> buildArtifactRepositories( List<Repository> repositories )
throws InvalidRepositoryException;
ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo )
throws InvalidRepositoryException;
ArtifactRepository buildArtifactRepository( Repository repo )
throws InvalidRepositoryException;
ArtifactRepository createLocalRepository( String url, String repositoryId )
throws IOException;
ArtifactRepository createRepository( String url, String repositoryId );
ArtifactRepository createRepository( String url, String repositoryId, ArtifactRepositoryPolicy snapshotsPolicy, ArtifactRepositoryPolicy releasesPolicy );
void setGlobalUpdatePolicy( String policy );
void setGlobalChecksumPolicy( String policy );
// Taken from RepositoryHelper
void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
throws ProjectBuildingException;
List<ArtifactRepository> buildArtifactRepositories( Model model )
throws ProjectBuildingException;
// PomArtifactResolver
void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactResolutionException, ArtifactNotFoundException;
Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type);
Artifact createArtifactWithClassifier(String groupId, String artifactId, String version, String type, String classifier);
Artifact createBuildArtifact(String groupId, String artifactId, String version, String packaging );
Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId );
List<ArtifactVersion> retrieveAvailableVersions(Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
throws ArtifactMetadataRetrievalException;
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
public ArtifactResolutionResult resolveTransitively(
Set<Artifact> artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories,
ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException;
Set<Artifact> createArtifacts(
List<Dependency> dependencies, String inheritedScope,
ArtifactFilter dependencyFilter, MavenProject project)
throws InvalidDependencyVersionException;
// WagonManager
ArtifactRepository getMirrorRepository( ArtifactRepository repository );
ArtifactRepository getMirror( ArtifactRepository originalRepository );
boolean matchPattern( ArtifactRepository originalRepository, String pattern );
boolean isExternalRepo( ArtifactRepository originalRepository );
void addMirror( String id, String mirrorOf, String url );
void setOnline( boolean online );
boolean isOnline();
void setInteractive( boolean interactive );
void setDownloadMonitor( TransferListener downloadMonitor );
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase );
void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions );
}

View File

@ -29,8 +29,6 @@ import java.io.IOException;
*/
public interface MavenProfilesBuilder
{
String ROLE = MavenProfilesBuilder.class.getName();
ProfilesRoot buildProfiles( File basedir )
throws IOException, XmlPullParserException;
}

View File

@ -19,7 +19,6 @@ package org.apache.maven.profiles.build;
* under the License.
*/
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
@ -35,6 +34,7 @@ import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.injection.ProfileInjector;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
@ -57,10 +57,8 @@ import java.util.List;
public class DefaultProfileAdvisor
implements ProfileAdvisor, LogEnabled, Contextualizable
{
public static final String ROLE_HINT = "default";
@Requirement
private RepositorySystem mavenTools;
private MavenRepositorySystem mavenTools;
@Requirement
private MavenProfilesBuilder profilesBuilder;

View File

@ -19,23 +19,20 @@ package org.apache.maven.project;
* under the License.
*/
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
@ -46,9 +43,10 @@ import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.build.ProfileAdvisor;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.builder.*;
import org.apache.maven.project.builder.PomInterpolatorTag;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.repository.MavenRepositorySystem;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
@ -74,22 +72,13 @@ public class DefaultMavenProjectBuilder
private ProfileAdvisor profileAdvisor;
@Requirement
private RepositorySystem mavenTools;
private MavenRepositorySystem repositorySystem;
@Requirement
private ProjectBuilder projectBuilder;
private Logger logger;
@Requirement
protected ArtifactResolver artifactResolver;
@Requirement
protected ArtifactMetadataSource artifactMetadataSource;
@Requirement
private ArtifactFactory artifactFactory;
//DO NOT USE, it is here only for backward compatibility reasons. The existing
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
@ -127,7 +116,7 @@ public class DefaultMavenProjectBuilder
}
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( );
artifactRepositories.addAll( mavenTools.buildArtifactRepositories( projectBuilder.getSuperModel() ) );
artifactRepositories.addAll( repositorySystem.buildArtifactRepositories( projectBuilder.getSuperModel() ) );
if(config.getRemoteRepositories() != null)
{
artifactRepositories.addAll(config.getRemoteRepositories());
@ -136,7 +125,7 @@ public class DefaultMavenProjectBuilder
MavenProject project = readModelFromLocalPath( "unknown",
projectDescriptor,
new DefaultPomArtifactResolver( config.getLocalRepository(),
artifactRepositories, artifactResolver ), config );
artifactRepositories, repositorySystem ), config );
project.setFile( projectDescriptor );
@ -189,14 +178,14 @@ public class DefaultMavenProjectBuilder
return project;
}
List<ArtifactRepository> artifactRepositories = new ArrayList<ArtifactRepository>( remoteArtifactRepositories );
artifactRepositories.addAll( mavenTools.buildArtifactRepositories( projectBuilder.getSuperModel() ) );
artifactRepositories.addAll( repositorySystem.buildArtifactRepositories( projectBuilder.getSuperModel() ) );
File f = (artifact.getFile() != null) ? artifact.getFile() : new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
mavenTools.findModelFromRepository( artifact, artifactRepositories, localRepository );
repositorySystem.findModelFromRepository( artifact, artifactRepositories, localRepository );
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository );
project = readModelFromLocalPath( "unknown", artifact.getFile(), new DefaultPomArtifactResolver( config.getLocalRepository(), artifactRepositories, artifactResolver ), config );
project = readModelFromLocalPath( "unknown", artifact.getFile(), new DefaultPomArtifactResolver( config.getLocalRepository(), artifactRepositories, repositorySystem ), config );
project = buildWithProfiles( project.getModel(), config, artifact.getFile(), project.getParentFile(), false );
artifact.setFile( f );
project.setVersion( artifact.getVersion() );
@ -221,7 +210,7 @@ public class DefaultMavenProjectBuilder
try
{
project = new MavenProject( superModel, artifactFactory, mavenTools, this, config );
project = new MavenProject( superModel, repositorySystem, this, config );
}
catch ( InvalidRepositoryException e )
{
@ -230,8 +219,8 @@ public class DefaultMavenProjectBuilder
try
{
project.setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
project.setPluginArtifactRepositories( mavenTools.buildArtifactRepositories( superModel.getRepositories() ) );
project.setRemoteArtifactRepositories( repositorySystem.buildArtifactRepositories( superModel.getRepositories() ) );
project.setPluginArtifactRepositories( repositorySystem.buildArtifactRepositories( superModel.getRepositories() ) );
}
catch ( InvalidRepositoryException e )
{
@ -250,7 +239,7 @@ public class DefaultMavenProjectBuilder
try
{
project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
project.setDependencyArtifacts( repositorySystem.createArtifacts( project.getDependencies(), null, null, project ) );
}
catch ( InvalidDependencyVersionException e )
{
@ -265,9 +254,9 @@ public class DefaultMavenProjectBuilder
.setLocalRepository( config.getLocalRepository() )
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
.setManagedVersionMap( project.getManagedVersionMap() )
.setMetadataSource( artifactMetadataSource );
.setMetadataSource( repositorySystem );
ArtifactResolutionResult result = artifactResolver.resolve( request );
ArtifactResolutionResult result = repositorySystem.resolve( request );
project.setArtifacts( result.getArtifacts() );
@ -323,12 +312,11 @@ public class DefaultMavenProjectBuilder
try
{
project = new MavenProject( model, artifactFactory, mavenTools, this, config );
project = new MavenProject( model, repositorySystem, this, config );
validateModel( model, projectDescriptor );
Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
project.getVersion(), project.getPackaging() );
Artifact projectArtifact = repositorySystem.createBuildArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getPackaging() );
project.setArtifact( projectArtifact );
project.setParentFile( parentDescriptor );
@ -371,11 +359,7 @@ public class DefaultMavenProjectBuilder
try
{
mavenProject = projectBuilder.buildFromLocalPath( projectDescriptor,
interpolatorProperties,
resolver,
config,
this);
mavenProject = projectBuilder.buildFromLocalPath( projectDescriptor, interpolatorProperties, resolver, config, this );
}
catch ( IOException e )
{

View File

@ -25,6 +25,7 @@ import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.project.PomArtifactResolver;
import org.apache.maven.repository.MavenRepositorySystem;
import java.io.File;
import java.io.IOException;
@ -49,7 +50,7 @@ public class DefaultPomArtifactResolver
/**
* Artifact resolver used to resolve artifacts
*/
private ArtifactResolver resolver;
private MavenRepositorySystem repositorySystem;
/**
* Constructor
@ -58,11 +59,11 @@ public class DefaultPomArtifactResolver
* @param remoteRepositories remote repositories used in resolving artifacts
* @param resolver artifact resolver used to resolve artifacts
*/
public DefaultPomArtifactResolver( ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactResolver resolver )
public DefaultPomArtifactResolver( ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, MavenRepositorySystem resolver )
{
this.localRepository = localRepository;
this.remoteRepositories = remoteRepositories;
this.resolver = resolver;
this.repositorySystem = resolver;
}
/**
@ -79,7 +80,7 @@ public class DefaultPomArtifactResolver
try
{
resolver.resolve( artifact, remoteRepositories, localRepository );
repositorySystem.resolve( artifact, localRepository, remoteRepositories );
}
catch ( ArtifactResolutionException e )
{

View File

@ -22,7 +22,6 @@ package org.apache.maven.project;
import java.io.*;
import java.util.*;
import org.apache.maven.RepositorySystem;
import org.apache.maven.mercury.PomProcessor;
import org.apache.maven.mercury.PomProcessorException;
import org.apache.maven.mercury.MavenDomainModel;
@ -37,8 +36,8 @@ import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.project.builder.*;
import org.apache.maven.project.builder.ProjectUri;
import org.apache.maven.project.builder.profile.ProfileContext;
import org.apache.maven.repository.MavenRepositorySystem;
import org.apache.maven.shared.model.*;
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
import org.codehaus.plexus.component.annotations.Component;
@ -58,10 +57,7 @@ public class DefaultProjectBuilder
implements ProjectBuilder, PomProcessor, LogEnabled
{
@Requirement
private ArtifactFactory artifactFactory;
@Requirement
private RepositorySystem mavenTools;
private MavenRepositorySystem repositorySystem;
@Requirement
List<ModelEventListener> listeners;
@ -314,8 +310,7 @@ public class DefaultProjectBuilder
try
{
MavenProject mavenProject = new MavenProject( convertFromInputStreamToModel(domainModel.getInputStream()),
artifactFactory,
mavenTools,
repositorySystem,
mavenProjectBuilder,
projectBuilderConfiguration );
@ -385,7 +380,7 @@ public class DefaultProjectBuilder
return domainModels;
}
Artifact artifactParent = artifactFactory.createParentArtifact( domainModel.getParentGroupId(),
Artifact artifactParent = repositorySystem.createParentArtifact( domainModel.getParentGroupId(),
domainModel.getParentArtifactId(), domainModel.getParentVersion() );
artifactResolver.resolve( artifactParent );

View File

@ -34,7 +34,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.Stack;
import org.apache.maven.RepositorySystem;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
@ -75,6 +74,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.project.artifact.ActiveProjectArtifact;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@ -163,12 +163,11 @@ public class MavenProject
private Stack<MavenProject> previousExecutionProjects = new Stack<MavenProject>();
//!! Components that need to be taken out of here
private ArtifactFactory artifactFactory;
private MavenProjectBuilder mavenProjectBuilder;
private ProjectBuilderConfiguration projectBuilderConfiguration;
private MavenRepositorySystem repositorySystem;
//
private File parentFile;
@ -213,7 +212,7 @@ public class MavenProject
* @param projectBuilderConfiguration
* @throws InvalidRepositoryException
*/
public MavenProject( Model model, ArtifactFactory artifactFactory, RepositorySystem mavenTools, MavenProjectBuilder mavenProjectBuilder, ProjectBuilderConfiguration projectBuilderConfiguration )
public MavenProject( Model model, MavenRepositorySystem mavenTools, MavenProjectBuilder mavenProjectBuilder, ProjectBuilderConfiguration projectBuilderConfiguration )
throws InvalidRepositoryException
{
if(model == null)
@ -221,11 +220,6 @@ public class MavenProject
throw new IllegalArgumentException("model: null");
}
if(artifactFactory == null)
{
throw new IllegalArgumentException("artifactFactory: null");
}
if(mavenTools == null)
{
throw new IllegalArgumentException("mavenTools: null");
@ -234,7 +228,7 @@ public class MavenProject
setModel( model );
this.mavenProjectBuilder = mavenProjectBuilder;
this.projectBuilderConfiguration = projectBuilderConfiguration;
this.artifactFactory = artifactFactory;
this.repositorySystem = mavenTools;
originalModel = model;
DistributionManagement dm = model.getDistributionManagement();
@ -1146,7 +1140,7 @@ public class MavenProject
return pluginArtifacts;
}
pluginArtifacts = new HashSet<Artifact>();
if ( artifactFactory != null )
if ( repositorySystem != null )
{
List<Plugin> plugins = getBuildPlugins();
for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext(); )
@ -1166,7 +1160,7 @@ public class MavenProject
Artifact artifact;
try
{
artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
VersionRange.createFromVersionSpec( version ) );
}
catch ( InvalidVersionSpecificationException e )
@ -1225,7 +1219,7 @@ public class MavenProject
Artifact artifact = null;
try
{
artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
VersionRange.createFromVersionSpec( version ) );
}
catch ( InvalidVersionSpecificationException e )
@ -1288,8 +1282,7 @@ public class MavenProject
try
{
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
artifact =
artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), versionRange );
artifact = repositorySystem.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), versionRange );
}
catch ( InvalidVersionSpecificationException e )
{
@ -1326,7 +1319,7 @@ public class MavenProject
if ( parentArtifact == null && model.getParent() != null )
{
Parent p = model.getParent();
parentArtifact = artifactFactory.createParentArtifact( p.getGroupId(), p.getArtifactId(), p.getVersion() );
parentArtifact = repositorySystem.createParentArtifact( p.getGroupId(), p.getArtifactId(), p.getVersion() );
}
return parentArtifact;
}
@ -1608,7 +1601,7 @@ public class MavenProject
}
Map<String, Artifact> map = null;
if ( artifactFactory != null )
if ( repositorySystem != null )
{
List<Dependency> deps;
@ -1625,7 +1618,7 @@ public class MavenProject
{
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
Artifact artifact = repositorySystem.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(),
d.getClassifier(), d.getScope(),
d.isOptional() );

View File

@ -1,4 +1,4 @@
package org.apache.maven;
package org.apache.maven.repository;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -46,10 +46,12 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
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.ArtifactResolver;
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;
@ -72,9 +74,9 @@ import org.codehaus.plexus.util.StringUtils;
/**
* @author Jason van Zyl
*/
@Component(role = RepositorySystem.class)
public class LegacyRepositorySystem
implements RepositorySystem, LogEnabled
@Component(role = MavenRepositorySystem.class)
public class LegacyMavenRepositorySystem
implements MavenRepositorySystem, LogEnabled
{
@Requirement
private ArtifactFactory artifactFactory;
@ -121,6 +123,39 @@ public class LegacyRepositorySystem
return artifactFactory.createProjectArtifact(groupId, artifactId, metaVersionId );
}
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional )
{
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope );
}
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope )
{
return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope, inheritedScope );
}
public Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange )
{
return artifactFactory.createExtensionArtifact( groupId, artifactId, versionRange );
}
public Artifact createParentArtifact( String groupId, String artifactId, String version )
{
return artifactFactory.createParentArtifact( groupId, artifactId, version );
}
public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange )
{
return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange );
}
public Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
throws InvalidDependencyVersionException
{
return MavenMetadataSource.createArtifacts( artifactFactory, dependencies, inheritedScope, dependencyFilter, project );
}
//
public List<ArtifactVersion> retrieveAvailableVersions(Artifact artifact,
ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories)
@ -142,18 +177,7 @@ public class LegacyRepositorySystem
ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException
{
return artifactResolver.resolveTransitively( artifacts, originatingArtifact, localRepository,
remoteRepositories, artifactMetadataSource, filter );
}
public Set<Artifact> createArtifacts(
List<Dependency> dependencies, String inheritedScope,
ArtifactFilter dependencyFilter, MavenProject project)
throws InvalidDependencyVersionException
{
return MavenMetadataSource.createArtifacts(artifactFactory,
dependencies, inheritedScope, dependencyFilter, project);
return artifactResolver.resolveTransitively(artifacts, originatingArtifact, remoteRepositories, localRepository, artifactMetadataSource );
}
// ----------------------------------------------------------------------------
@ -464,7 +488,6 @@ public class LegacyRepositorySystem
throws ArtifactResolutionException, ArtifactNotFoundException
{
File artifactFile = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
// FIXME: Not sure whether this is just intermediate code but the call belows wrecks havoc on system dependencies
artifact.setFile( artifactFile );
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
}
@ -697,6 +720,26 @@ public class LegacyRepositorySystem
}
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
return artifactResolver.resolve( request );
}
// These two methods are here so that the ArtifactMetadataSource is implemented so that I can pass this into an ArtifactResolutionRequest.
// Intermediate measure before separating the RepositorySystem out into its own module.
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException
{
return artifactMetadataSource.retrieveAvailableVersionsFromDeploymentRepository( artifact, localRepository, remoteRepository );
}
public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
return artifactMetadataSource.retrieveRelocatedArtifact( artifact, localRepository, remoteRepositories );
}
// Test for this stuff
/*

View File

@ -0,0 +1,158 @@
package org.apache.maven.repository;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
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;
/**
* @author Jason van Zyl
*/
public interface MavenRepositorySystem
extends ArtifactMetadataSource // This needs to be removed
{
// Artifact creation: This needs to be reduced to fewer, if not one, method. We also need to get rid of the legacy
// VersionRange from the system.
Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type );
Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type, String classifier );
Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging );
Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId );
Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange );
Artifact createExtensionArtifact( String groupId, String artifactId, VersionRange versionRange );
Artifact createParentArtifact( String groupId, String artifactId, String version );
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, boolean optional );
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, String classifier, String scope, String inheritedScope );
Set<Artifact> createArtifacts( List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project )
throws InvalidDependencyVersionException;
// Repository creation
List<ArtifactRepository> buildArtifactRepositories( List<Repository> repositories )
throws InvalidRepositoryException;
ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo )
throws InvalidRepositoryException;
ArtifactRepository buildArtifactRepository( Repository repo )
throws InvalidRepositoryException;
ArtifactRepository createLocalRepository( String url, String repositoryId )
throws IOException;
ArtifactRepository createRepository( String url, String repositoryId );
ArtifactRepository createRepository( String url, String repositoryId, ArtifactRepositoryPolicy snapshotsPolicy, ArtifactRepositoryPolicy releasesPolicy );
List<ArtifactRepository> buildArtifactRepositories( Model model )
throws ProjectBuildingException;
void setGlobalUpdatePolicy( String policy );
void setGlobalChecksumPolicy( String policy );
// Artifact resolution
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
void resolve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException;
void findModelFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
throws ProjectBuildingException;
// Version retrieval or metadata operations
ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
List<ArtifactVersion> retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
// These are only showing up in tests, not called from anywhere else in the core
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws ArtifactMetadataRetrievalException;
public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException;
// Mirrors
ArtifactRepository getMirrorRepository( ArtifactRepository repository );
ArtifactRepository getMirror( ArtifactRepository originalRepository );
boolean matchPattern( ArtifactRepository originalRepository, String pattern );
boolean isExternalRepo( ArtifactRepository originalRepository );
void addMirror( String id, String mirrorOf, String url );
// Network enablement
void setOnline( boolean online );
boolean isOnline();
// This doesn't belong here
void setInteractive( boolean interactive );
void setDownloadMonitor( TransferListener downloadMonitor );
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase );
void addPermissionInfo( String repositoryId, String filePermissions, String directoryPermissions );
}

View File

@ -24,9 +24,6 @@ import java.util.Iterator;
import org.apache.maven.artifact.Artifact;
/**
* @todo relocate to maven-artifact in entirety
*/
public class ProjectClasspathTest
extends AbstractMavenProjectTestCase
{
@ -37,14 +34,6 @@ public class ProjectClasspathTest
{
File f = getFileForClasspathResource( dir + "project-with-scoped-dependencies.xml" );
// assertEquals( TestArtifactResolver.class, getContainer().lookup( ArtifactResolver.ROLE ).getClass() );
TestProjectBuilder builder = (TestProjectBuilder) getContainer().lookup( MavenProjectBuilder.class, "test" );
TestArtifactResolver testArtifactResolver = getContainer().lookup( TestArtifactResolver.class );
builder.setArtifactResolver( testArtifactResolver );
builder.setArtifactMetadataSource( testArtifactResolver.source() );
MavenProject project = getProjectWithDependencies( f );
Artifact artifact;
@ -63,6 +52,8 @@ public class ProjectClasspathTest
artifact = getArtifact( project, "maven-test-test", "scope-test" );
assertNull( "Check no test dependencies are transitive", artifact );
artifact = getArtifact( project, "maven-test-test", "scope-compile" );
System.out.println( "a = " + artifact );
System.out.println( "b = " + artifact.getScope() );
assertEquals( "Check scope", "test", artifact.getScope() );
artifact = getArtifact( project, "maven-test-test", "scope-default" );
assertEquals( "Check scope", "test", artifact.getScope() );

View File

@ -19,63 +19,60 @@ package org.apache.maven.project;
* under the License.
*/
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
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.ArtifactRepositoryFactory;
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.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.*;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.PlexusConstants;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
@Component(role=ArtifactResolver.class, hint="test")
public class TestArtifactResolver
extends DefaultArtifactResolver
implements Contextualizable
{
public static final String ROLE = TestArtifactResolver.class.getName();
private ArtifactRepositoryFactory repositoryFactory;
@Requirement
private PlexusContainer container;
@Requirement
private MavenRepositorySystem repositorySystem;
static class Source
implements ArtifactMetadataSource
{
private ArtifactFactory artifactFactory;
private final ArtifactRepositoryFactory repositoryFactory;
private final PlexusContainer container;
public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory,
PlexusContainer container )
private MavenRepositorySystem repositorySystem;
public Source( MavenRepositorySystem repositorySystem, PlexusContainer container )
{
this.artifactFactory = artifactFactory;
this.repositoryFactory = repositoryFactory;
this.repositorySystem = repositorySystem;
this.container = container;
}
@ -129,7 +126,7 @@ public class TestArtifactResolver
try
{
artifactRepositories =
ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
repositorySystem.buildArtifactRepositories( model.getRepositories() );
}
catch ( InvalidRepositoryException e )
{
@ -174,9 +171,13 @@ public class TestArtifactResolver
}
VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(),
d.getClassifier(), scope,
Artifact artifact = repositorySystem.createDependencyArtifact( d.getGroupId(),
d.getArtifactId(),
versionRange,
d.getType(),
d.getClassifier(),
scope,
inheritedScope );
if ( artifact != null )
{
@ -198,7 +199,7 @@ public class TestArtifactResolver
public Source source()
{
return new Source( artifactFactory, repositoryFactory, container );
return new Source( repositorySystem, container );
}
/**
@ -218,7 +219,7 @@ public class TestArtifactResolver
throws ArtifactResolutionException, ArtifactNotFoundException
{
return super.resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories,
new Source( artifactFactory, repositoryFactory, container ), filter );
new Source( repositorySystem, container ), filter );
}
@Override
@ -228,117 +229,6 @@ public class TestArtifactResolver
throws ArtifactResolutionException, ArtifactNotFoundException
{
return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository,
new Source( artifactFactory, repositoryFactory, container ) );
new Source( repositorySystem, container ) );
}
public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
public static final class ProjectUtils
{
private ProjectUtils()
{
}
public static List buildArtifactRepositories( List repositories,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
throws InvalidRepositoryException
{
List repos = new ArrayList();
for ( Iterator i = repositories.iterator(); i.hasNext(); )
{
Repository mavenRepo = (Repository) i.next();
ArtifactRepository artifactRepo =
buildArtifactRepository( mavenRepo, artifactRepositoryFactory, container );
if ( !repos.contains( artifactRepo ) )
{
repos.add( artifactRepo );
}
}
return repos;
}
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
throws InvalidRepositoryException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, repo.getLayout(),
repo.isUniqueVersion() );
}
else
{
return null;
}
}
public static ArtifactRepository buildArtifactRepository( Repository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
throws InvalidRepositoryException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
if ( id == null || id.trim().length() < 1 )
{
throw new MissingRepositoryElementException( "Repository ID must not be empty (URL is: " + url + ")." );
}
if ( url == null || url.trim().length() < 1 )
{
throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").", id );
}
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() );
return artifactRepositoryFactory.createArtifactRepository( id, url, repo.getLayout(), snapshots, releases );
}
else
{
return null;
}
}
private static ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy )
{
boolean enabled = true;
String updatePolicy = null;
String checksumPolicy = null;
if ( policy != null )
{
enabled = policy.isEnabled();
if ( policy.getUpdatePolicy() != null )
{
updatePolicy = policy.getUpdatePolicy();
}
if ( policy.getChecksumPolicy() != null )
{
checksumPolicy = policy.getChecksumPolicy();
}
}
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
}
}
}

View File

@ -19,19 +19,14 @@ package org.apache.maven.project;
* under the License.
*/
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
public class TestProjectBuilder extends DefaultMavenProjectBuilder
@Component(role=MavenProjectBuilder.class,hint="test")
public class TestProjectBuilder
extends DefaultMavenProjectBuilder
{
public void setArtifactResolver( ArtifactResolver resolver )
{
artifactResolver = resolver;
}
public void setArtifactMetadataSource( ArtifactMetadataSource metadataSource )
{
artifactMetadataSource = metadataSource;
}
@Requirement(hint="test")
private ArtifactResolver artifactResolver;
}

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.FileInputStream;
import java.util.*;
import org.apache.maven.RepositorySystem;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.activation.DefaultProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationContext;
@ -35,6 +34,7 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.project.harness.PomTestWrapper;
import org.apache.maven.project.*;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@ -52,7 +52,7 @@ public class PomConstructionTest
private MavenProjectBuilder mavenProjectBuilder;
private RepositorySystem mavenTools;
private MavenRepositorySystem mavenTools;
private PomArtifactResolver pomArtifactResolver;
@ -67,7 +67,7 @@ public class PomConstructionTest
testMixinDirectory = new File( getBasedir(), BASE_MIXIN_DIR );
mavenProjectBuilder = lookup( MavenProjectBuilder.class );
projectBuilder = lookup( ProjectBuilder.class );
mavenTools = lookup( RepositorySystem.class );
mavenTools = lookup( MavenRepositorySystem.class );
pomArtifactResolver = new PomArtifactResolver()
{

View File

@ -1,102 +0,0 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<plexus>
<components>
<component>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.injection.TestProfileInjector</implementation>
</component>
<component>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.profiles.build.DefaultProfileAdvisor</implementation>
<requirements>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.TestArtifactResolver</role>
<implementation>org.apache.maven.project.TestArtifactResolver</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.validation.ModelValidator</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
</requirement>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
</requirements>
</component>
</components>
</plexus>

View File

@ -1,105 +0,0 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<plexus>
<components><!--Eliminate this component after Mercury Integration-->
<component>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.injection.TestProfileInjector</implementation>
</component>
<component>
<role>org.apache.maven.project.TestArtifactResolver</role>
<implementation>org.apache.maven.project.TestArtifactResolver</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.manager.WagonManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.profiles.build.DefaultProfileAdvisor</implementation>
<requirements>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.injection.ProfileInjector</role>
<role-hint>test</role-hint>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.ProjectBuilder</role>
<role-hint>default</role-hint>
<implementation>org.apache.maven.project.DefaultProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
</requirements>
</component>
<component>
<role>org.apache.maven.project.MavenProjectBuilder</role>
<role-hint>test</role-hint>
<implementation>org.apache.maven.project.TestProjectBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.project.ProjectBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.profiles.build.ProfileAdvisor</role>
<role-hint>default</role-hint>
</requirement>
<requirement>
<role>org.apache.maven.profiles.MavenProfilesBuilder</role>
</requirement>
<requirement>
<role>org.apache.maven.project.validation.ModelValidator</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
</requirement>
<requirement>
<role>org.apache.maven.RepositorySystem</role>
</requirement>
</requirements>
</component>
</components>
</plexus>

View File

@ -157,6 +157,7 @@ under the License.
<execution>
<goals>
<goal>generate-metadata</goal>
<goal>generate-test-metadata</goal>
</goals>
</execution>
</executions>