mirror of https://github.com/apache/maven.git
PR: MNG-505
artifact refactoring to facilitate version ranges git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6f81043b7b
commit
810d4a3276
|
@ -16,21 +16,21 @@ package org.apache.maven.artifact.ant;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.settings.Mirror;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.settings.Server;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.profiles.activation.ProfileActivationUtils;
|
import org.apache.maven.profiles.activation.ProfileActivationUtils;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
import org.apache.maven.settings.Mirror;
|
||||||
|
import org.apache.maven.settings.Server;
|
||||||
|
import org.apache.maven.settings.Settings;
|
||||||
|
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
@ -104,20 +104,20 @@ public abstract class AbstractArtifactTask
|
||||||
manager.addProxy( proxy.getType(), proxy.getHost(), proxy.getPort(), proxy.getUserName(),
|
manager.addProxy( proxy.getType(), proxy.getHost(), proxy.getPort(), proxy.getUserName(),
|
||||||
proxy.getPassword(), proxy.getNonProxyHosts() );
|
proxy.getPassword(), proxy.getNonProxyHosts() );
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtifactRepositoryFactory repositoryFactory = null;
|
ArtifactRepositoryFactory repositoryFactory = null;
|
||||||
|
|
||||||
ArtifactRepository artifactRepository;
|
ArtifactRepository artifactRepository;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
repositoryFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||||
|
|
||||||
String snapshotPolicy = repository.getSnapshotPolicy();
|
String snapshotPolicy = repository.getSnapshotPolicy();
|
||||||
String checksumPolicy = repository.getChecksumPolicy();
|
String checksumPolicy = repository.getChecksumPolicy();
|
||||||
|
|
||||||
artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(),
|
artifactRepository = repositoryFactory.createArtifactRepository( "remote", repository.getUrl(),
|
||||||
repositoryLayout, snapshotPolicy,
|
repositoryLayout, snapshotPolicy,
|
||||||
checksumPolicy );
|
checksumPolicy );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -260,9 +260,9 @@ public abstract class AbstractArtifactTask
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ClassWorld classWorld = new ClassWorld();
|
ClassWorld classWorld = new ClassWorld();
|
||||||
|
|
||||||
ClassRealm classRealm = classWorld.newRealm( "plexus.core", getClass().getClassLoader() );
|
classWorld.newRealm( "plexus.core", getClass().getClassLoader() );
|
||||||
|
|
||||||
embedder.start( classWorld );
|
embedder.start( classWorld );
|
||||||
}
|
}
|
||||||
catch ( PlexusContainerException e )
|
catch ( PlexusContainerException e )
|
||||||
|
@ -273,7 +273,7 @@ public abstract class AbstractArtifactTask
|
||||||
{
|
{
|
||||||
throw new BuildException( "Unable to create embedder ClassRealm", e );
|
throw new BuildException( "Unable to create embedder ClassRealm", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
getProject().addReference( Embedder.class.getName(), embedder );
|
getProject().addReference( Embedder.class.getName(), embedder );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,18 +307,18 @@ public abstract class AbstractArtifactTask
|
||||||
protected Pom createDummyPom()
|
protected Pom createDummyPom()
|
||||||
{
|
{
|
||||||
Model mavenModel = new Model();
|
Model mavenModel = new Model();
|
||||||
|
|
||||||
mavenModel.setGroupId( "unspecified" );
|
mavenModel.setGroupId( "unspecified" );
|
||||||
mavenModel.setArtifactId( "unspecified" );
|
mavenModel.setArtifactId( "unspecified" );
|
||||||
mavenModel.setVersion( "0.0" );
|
mavenModel.setVersion( "0.0" );
|
||||||
mavenModel.setPackaging( "jar" );
|
mavenModel.setPackaging( "jar" );
|
||||||
|
|
||||||
MavenProject mavenProject = new MavenProject( mavenModel );
|
MavenProject mavenProject = new MavenProject( mavenModel );
|
||||||
|
|
||||||
Pom pom = new Pom();
|
Pom pom = new Pom();
|
||||||
|
|
||||||
pom.setMavenProject( mavenProject );
|
pom.setMavenProject( mavenProject );
|
||||||
|
|
||||||
return pom;
|
return pom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,8 +360,6 @@ public abstract class AbstractArtifactTask
|
||||||
{
|
{
|
||||||
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
|
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
|
||||||
Artifact artifact = factory.createArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), null,
|
return factory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom.getVersion(), pom.getPackaging() );
|
||||||
pom.getPackaging() );
|
|
||||||
return artifact;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class DependenciesTask
|
||||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||||
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||||
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
MavenMetadataSource metadataSource = new MavenMetadataSource( resolver, projectBuilder, artifactFactory );
|
MavenMetadataSource metadataSource = new MavenMetadataSource( projectBuilder, artifactFactory );
|
||||||
|
|
||||||
List dependencies = this.dependencies;
|
List dependencies = this.dependencies;
|
||||||
|
|
||||||
|
@ -101,8 +101,8 @@ public class DependenciesTask
|
||||||
ArtifactResolutionResult result;
|
ArtifactResolutionResult result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Artifact pomArtifact = artifactFactory.createArtifact( pom.getGroupId(), pom.getArtifactId(),
|
Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(),
|
||||||
pom.getVersion(), null, pom.getPackaging() );
|
pom.getVersion(), pom.getPackaging() );
|
||||||
|
|
||||||
List listeners = Collections.EMPTY_LIST;
|
List listeners = Collections.EMPTY_LIST;
|
||||||
if ( verbose )
|
if ( verbose )
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.apache.maven.artifact;
|
package org.apache.maven.artifact;
|
||||||
|
|
||||||
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
|
@ -56,10 +56,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
"legacy" );
|
"legacy" );
|
||||||
|
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "test", "file://" + f.getPath(),
|
return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout );
|
||||||
repoLayout );
|
|
||||||
|
|
||||||
return localRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getRepositoryLayout()
|
protected String getRepositoryLayout()
|
||||||
|
@ -77,10 +74,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
"legacy" );
|
"legacy" );
|
||||||
|
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + f.getPath(),
|
return (ArtifactRepository) new DefaultArtifactRepository( "local", "file://" + f.getPath(), repoLayout );
|
||||||
repoLayout );
|
|
||||||
|
|
||||||
return localRepository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository remoteRepository()
|
protected ArtifactRepository remoteRepository()
|
||||||
|
@ -93,11 +87,9 @@ public abstract class ArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
"legacy" );
|
"legacy" );
|
||||||
|
|
||||||
ArtifactRepository repository = new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
return (ArtifactRepository) new DefaultArtifactRepository( "test", "file://" + f.getPath(), repoLayout,
|
||||||
ArtifactRepository.SNAPSHOT_POLICY_NEVER,
|
ArtifactRepository.SNAPSHOT_POLICY_NEVER,
|
||||||
ArtifactRepository.CHECKSUM_POLICY_WARN );
|
ArtifactRepository.CHECKSUM_POLICY_WARN );
|
||||||
|
|
||||||
return repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArtifactRepository badRemoteRepository()
|
protected ArtifactRepository badRemoteRepository()
|
||||||
|
@ -106,10 +98,7 @@ public abstract class ArtifactComponentTestCase
|
||||||
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
"legacy" );
|
"legacy" );
|
||||||
|
|
||||||
ArtifactRepository repository = new DefaultArtifactRepository( "test", "http://foo.bar/repository",
|
return (ArtifactRepository) new DefaultArtifactRepository( "test", "http://foo.bar/repository", repoLayout );
|
||||||
repoLayout );
|
|
||||||
|
|
||||||
return repository;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertRemoteArtifactPresent( Artifact artifact )
|
protected void assertRemoteArtifactPresent( Artifact artifact )
|
||||||
|
@ -242,22 +231,24 @@ public abstract class ArtifactComponentTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Artifact createArtifact( String artifactId, String version )
|
protected Artifact createArtifact( String artifactId, String version )
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
return createArtifact( artifactId, version, "jar" );
|
return createArtifact( artifactId, version, "jar" );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Artifact createArtifact( String artifactId, String version, String type )
|
protected Artifact createArtifact( String artifactId, String version, String type )
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// TODO: fix handler instantiation
|
return createArtifact( "org.apache.maven", artifactId, version, type );
|
||||||
return new DefaultArtifact( "org.apache.maven", artifactId, version, null, type, null,
|
|
||||||
new DefaultArtifactHandler( type ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
|
protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// TODO: fix handler instantiation
|
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
return new DefaultArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE, type, null,
|
|
||||||
new DefaultArtifactHandler( type ) );
|
// TODO: used to be SCOPE_COMPILE, check
|
||||||
|
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteLocalArtifact( Artifact artifact )
|
protected void deleteLocalArtifact( Artifact artifact )
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.ArtifactComponentTestCase;
|
import org.apache.maven.artifact.ArtifactComponentTestCase;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
import org.apache.maven.artifact.metadata.ResolutionGroup;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -82,6 +83,7 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
|
protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
// for the anonymous classes
|
// for the anonymous classes
|
||||||
return super.createArtifact( groupId, artifactId, version, type );
|
return super.createArtifact( groupId, artifactId, version, type );
|
||||||
|
@ -97,12 +99,20 @@ public class ArtifactResolverTest
|
||||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
||||||
{
|
{
|
||||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
Set dependencies = new HashSet();
|
Set dependencies = new HashSet();
|
||||||
|
|
||||||
if ( artifact.getArtifactId().equals( "g" ) )
|
if ( artifact.getArtifactId().equals( "g" ) )
|
||||||
{
|
{
|
||||||
dependencies.add( createArtifact( "org.apache.maven", "h", "1.0", "jar" ) );
|
try
|
||||||
|
{
|
||||||
|
dependencies.add( createArtifact( "org.apache.maven", "h", "1.0", "jar" ) );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( dependencies, remoteRepositories );
|
return new ResolutionGroup( dependencies, remoteRepositories );
|
||||||
|
@ -136,12 +146,20 @@ public class ArtifactResolverTest
|
||||||
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
ArtifactMetadataSource mds = new ArtifactMetadataSource()
|
||||||
{
|
{
|
||||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
Set dependencies = new HashSet();
|
Set dependencies = new HashSet();
|
||||||
|
|
||||||
if ( artifact.getArtifactId().equals( "i" ) )
|
if ( artifact.getArtifactId().equals( "i" ) )
|
||||||
{
|
{
|
||||||
dependencies.add( createArtifact( "org.apache.maven", "j", "1.0", "jar" ) );
|
try
|
||||||
|
{
|
||||||
|
dependencies.add( createArtifact( "org.apache.maven", "j", "1.0", "jar" ) );
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( dependencies, remoteRepositories );
|
return new ResolutionGroup( dependencies, remoteRepositories );
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -71,8 +72,7 @@ public class DefaultArtifact
|
||||||
|
|
||||||
private List dependencyTrail;
|
private List dependencyTrail;
|
||||||
|
|
||||||
// TODO: direct all through the artifact factory
|
public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type,
|
||||||
public DefaultArtifact( String groupId, String artifactId, String version, String scope, String type,
|
|
||||||
String classifier, ArtifactHandler artifactHandler )
|
String classifier, ArtifactHandler artifactHandler )
|
||||||
{
|
{
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
|
@ -80,7 +80,7 @@ public class DefaultArtifact
|
||||||
this.artifactId = artifactId;
|
this.artifactId = artifactId;
|
||||||
|
|
||||||
// TODO: this would be where we might have a min/max instead
|
// TODO: this would be where we might have a min/max instead
|
||||||
this.version = version;
|
this.version = versionRange.getVersion();
|
||||||
|
|
||||||
this.artifactHandler = artifactHandler;
|
this.artifactHandler = artifactHandler;
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,43 @@ package org.apache.maven.artifact.factory;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
|
||||||
public interface ArtifactFactory
|
public interface ArtifactFactory
|
||||||
{
|
{
|
||||||
static String ROLE = ArtifactFactory.class.getName();
|
static String ROLE = ArtifactFactory.class.getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
String inheritedScope );
|
String inheritedScope );
|
||||||
|
|
||||||
Artifact createArtifact( String groupId, String artifactId, String knownVersion, String scope, String type );
|
// TODO: deprecate and chase down (probably used for copying only)
|
||||||
|
Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type );
|
||||||
Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope,
|
|
||||||
String type, String classifier );
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope, String type,
|
||||||
|
String classifier );
|
||||||
|
|
||||||
|
Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
|
||||||
|
String classifier );
|
||||||
|
|
||||||
|
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String scope );
|
||||||
|
|
||||||
|
Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String scope, String inheritedScope );
|
||||||
|
|
||||||
|
Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging );
|
||||||
|
|
||||||
|
Artifact createProjectArtifact( String groupId, String artifactId, String version );
|
||||||
|
|
||||||
|
Artifact createParentArtifact( String groupId, String artifactId, String version );
|
||||||
|
|
||||||
|
Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange );
|
||||||
|
|
||||||
|
Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope );
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
import org.apache.maven.artifact.DefaultArtifact;
|
||||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
|
|
||||||
public class DefaultArtifactFactory
|
public class DefaultArtifactFactory
|
||||||
implements ArtifactFactory
|
implements ArtifactFactory
|
||||||
|
@ -47,6 +48,49 @@ public class DefaultArtifactFactory
|
||||||
return createArtifact( groupId, artifactId, version, scope, type, classifier, null );
|
return createArtifact( groupId, artifactId, version, scope, type, classifier, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String type,
|
||||||
|
String classifier )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, version, null, type, classifier, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String scope )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, versionRange, null, type, null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type,
|
||||||
|
String scope, String inheritedScope )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, versionRange, scope, type, null, inheritedScope );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createBuildArtifact( String groupId, String artifactId, String version, String packaging )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, version, null, packaging, null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createProjectArtifact( String groupId, String artifactId, String version )
|
||||||
|
{
|
||||||
|
return createProjectArtifact( groupId, artifactId, version, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createParentArtifact( String groupId, String artifactId, String version )
|
||||||
|
{
|
||||||
|
return createProjectArtifact( groupId, artifactId, version );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, versionRange, Artifact.SCOPE_RUNTIME, "maven-plugin", null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Artifact createProjectArtifact( String groupId, String artifactId, String version, String scope )
|
||||||
|
{
|
||||||
|
return createArtifact( groupId, artifactId, version, scope, "pom" );
|
||||||
|
}
|
||||||
|
|
||||||
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
String inheritedScope )
|
String inheritedScope )
|
||||||
{
|
{
|
||||||
|
@ -55,6 +99,22 @@ public class DefaultArtifactFactory
|
||||||
|
|
||||||
private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
private Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
|
||||||
String classifier, String inheritedScope )
|
String classifier, String inheritedScope )
|
||||||
|
{
|
||||||
|
// TODO: better constructor
|
||||||
|
VersionRange versionRange;
|
||||||
|
if ( version != null )
|
||||||
|
{
|
||||||
|
versionRange = new VersionRange( "[" + version + "]" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
versionRange = new VersionRange( null );
|
||||||
|
}
|
||||||
|
return createArtifact( groupId, artifactId, versionRange, scope, type, classifier, inheritedScope );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Artifact createArtifact( String groupId, String artifactId, VersionRange versionRange, String scope,
|
||||||
|
String type, String classifier, String inheritedScope )
|
||||||
{
|
{
|
||||||
// TODO: can refactor - inherited scope calculation belongs in the collector, use scope handler
|
// TODO: can refactor - inherited scope calculation belongs in the collector, use scope handler
|
||||||
|
|
||||||
|
@ -87,6 +147,6 @@ public class DefaultArtifactFactory
|
||||||
|
|
||||||
ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type );
|
ArtifactHandler handler = artifactHandlerManager.getArtifactHandler( type );
|
||||||
|
|
||||||
return new DefaultArtifact( groupId, artifactId, version, desiredScope, type, classifier, handler );
|
return new DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, classifier, handler );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.apache.maven.artifact.versioning;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a version range from a specification.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class VersionRange
|
||||||
|
{
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public VersionRange( String spec )
|
||||||
|
{
|
||||||
|
if ( spec != null )
|
||||||
|
{
|
||||||
|
// temporary!
|
||||||
|
if ( spec.startsWith( "[" ) )
|
||||||
|
{
|
||||||
|
spec = spec.substring( 1, spec.length() - 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.version = spec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion()
|
||||||
|
{
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.InversionArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.InversionArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.ReportPlugin;
|
import org.apache.maven.model.ReportPlugin;
|
||||||
|
@ -165,8 +166,8 @@ public class DefaultPluginManager
|
||||||
String groupId = plugin.getGroupId();
|
String groupId = plugin.getGroupId();
|
||||||
String artifactId = plugin.getArtifactId();
|
String artifactId = plugin.getArtifactId();
|
||||||
|
|
||||||
plugin.setVersion( pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings,
|
plugin.setVersion(
|
||||||
localRepository ) );
|
pluginVersionManager.resolvePluginVersion( groupId, artifactId, project, settings, localRepository ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
||||||
|
@ -174,14 +175,13 @@ public class DefaultPluginManager
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Artifact pluginArtifact = artifactFactory.createArtifact( plugin.getGroupId(),
|
VersionRange versionRange = new VersionRange( plugin.getVersion() );
|
||||||
plugin.getArtifactId(),
|
Artifact pluginArtifact = artifactFactory.createPluginArtifact( plugin.getGroupId(),
|
||||||
plugin.getVersion(),
|
plugin.getArtifactId(), versionRange );
|
||||||
Artifact.SCOPE_RUNTIME,
|
|
||||||
MojoDescriptor.MAVEN_PLUGIN );
|
|
||||||
|
|
||||||
// TODO: [jc; 2005-july-06] what's this for?
|
// I think this ensures the plugin is not resolved multiple times
|
||||||
//plugin.setVersion( pluginArtifact.getBaseVersion() );
|
// TODO: put it back
|
||||||
|
// plugin.setVersion( pluginArtifact.getBaseVersion() );
|
||||||
|
|
||||||
addPlugin( plugin, pluginArtifact, project, localRepository );
|
addPlugin( plugin, pluginArtifact, project, localRepository );
|
||||||
|
|
||||||
|
@ -198,10 +198,9 @@ public class DefaultPluginManager
|
||||||
String artifactId = plugin.getArtifactId();
|
String artifactId = plugin.getArtifactId();
|
||||||
String version = plugin.getVersion();
|
String version = plugin.getVersion();
|
||||||
|
|
||||||
if (
|
if ( ( groupId == null || artifactId == null || version == null || ( groupId.equals( e.getGroupId() ) &&
|
||||||
( groupId == null || artifactId == null || version == null ||
|
artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) ) ) &&
|
||||||
( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
"maven-plugin".equals( e.getType() ) )
|
||||||
version.equals( e.getVersion() ) ) ) && "maven-plugin".equals( e.getType() ) )
|
|
||||||
{
|
{
|
||||||
throw new PluginNotFoundException( e );
|
throw new PluginNotFoundException( e );
|
||||||
}
|
}
|
||||||
|
@ -222,7 +221,8 @@ public class DefaultPluginManager
|
||||||
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
|
artifactResolver.resolve( pluginArtifact, project.getPluginArtifactRepositories(), localRepository );
|
||||||
|
|
||||||
PlexusContainer child = container.createChildContainer( plugin.getKey(), Collections
|
PlexusContainer child = container.createChildContainer( plugin.getKey(), Collections
|
||||||
.singletonList( pluginArtifact.getFile() ), Collections.EMPTY_MAP, Collections.singletonList( pluginCollector ) );
|
.singletonList( pluginArtifact.getFile() ), Collections.EMPTY_MAP,
|
||||||
|
Collections.singletonList( pluginCollector ) );
|
||||||
|
|
||||||
// this plugin's descriptor should have been discovered in the child creation, so we should be able to
|
// this plugin's descriptor should have been discovered in the child creation, so we should be able to
|
||||||
// circle around and set the artifacts and class realm
|
// circle around and set the artifacts and class realm
|
||||||
|
@ -328,10 +328,9 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project,
|
public List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
|
||||||
MavenSession session, ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException,
|
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException, ArtifactResolutionException
|
||||||
ArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
Plugin forLookup = new Plugin();
|
Plugin forLookup = new Plugin();
|
||||||
forLookup.setGroupId( reportPlugin.getGroupId() );
|
forLookup.setGroupId( reportPlugin.getGroupId() );
|
||||||
|
@ -360,7 +359,8 @@ public class DefaultPluginManager
|
||||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, id );
|
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, id );
|
||||||
|
|
||||||
String executionId = mojoExecution.getExecutionId();
|
String executionId = mojoExecution.getExecutionId();
|
||||||
Xpp3Dom dom = project.getReportConfiguration( reportPlugin.getGroupId(), reportPlugin.getArtifactId(), executionId );
|
Xpp3Dom dom = project.getReportConfiguration( reportPlugin.getGroupId(),
|
||||||
|
reportPlugin.getArtifactId(), executionId );
|
||||||
|
|
||||||
reports.add( getConfiguredMojo( mojoDescriptor, session, dom, project ) );
|
reports.add( getConfiguredMojo( mojoDescriptor, session, dom, project ) );
|
||||||
}
|
}
|
||||||
|
@ -451,8 +451,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
MavenMetadataSource metadataSource = new MavenMetadataSource( mavenProjectBuilder, artifactFactory );
|
||||||
artifactFactory );
|
|
||||||
|
|
||||||
List remoteRepositories = new ArrayList();
|
List remoteRepositories = new ArrayList();
|
||||||
|
|
||||||
|
@ -543,9 +542,8 @@ public class DefaultPluginManager
|
||||||
// ideally, this would be elevated above the true debug output, but below the default INFO level...
|
// ideally, this would be elevated above the true debug output, but below the default INFO level...
|
||||||
// [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or
|
// [BP] (2004-07-18): need to understand the context more but would prefer this could be either WARN or
|
||||||
// removed - shouldn't need DEBUG to diagnose a problem most of the time.
|
// removed - shouldn't need DEBUG to diagnose a problem most of the time.
|
||||||
getLogger().debug(
|
getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" +
|
||||||
"*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" +
|
mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
|
||||||
mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,9 +629,8 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
if ( fieldValue != null )
|
if ( fieldValue != null )
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
getLogger().warn( "DEPRECATED: using default-value to set the default value of field '" +
|
||||||
"DEPRECATED: using default-value to set the default value of field '" +
|
parameter.getName() + "'" );
|
||||||
parameter.getName() + "'" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( NoSuchFieldException e )
|
catch ( NoSuchFieldException e )
|
||||||
|
@ -920,14 +917,13 @@ public class DefaultPluginManager
|
||||||
ArtifactFactory artifactFactory, MavenProject project )
|
ArtifactFactory artifactFactory, MavenProject project )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
MavenMetadataSource sourceReader = new MavenMetadataSource( mavenProjectBuilder, artifactFactory );
|
||||||
artifactFactory );
|
|
||||||
|
|
||||||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||||
|
|
||||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||||
Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
Artifact artifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
|
||||||
project.getVersion(), null, project.getPackaging() );
|
project.getVersion(), project.getPackaging() );
|
||||||
|
|
||||||
// TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
|
// TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
|
||||||
// check this with yourkit as a hot spot.
|
// check this with yourkit as a hot spot.
|
||||||
|
|
|
@ -601,11 +601,10 @@ public class DefaultPluginVersionManager
|
||||||
private String resolveMetaVersion( String groupId, String artifactId, List remoteRepositories,
|
private String resolveMetaVersion( String groupId, String artifactId, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, String metaVersionId )
|
ArtifactRepository localRepository, String metaVersionId )
|
||||||
{
|
{
|
||||||
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, metaVersionId, Artifact.SCOPE_RUNTIME,
|
// TODO: check - this was SCOPE_RUNTIME before, now is null
|
||||||
"pom" );
|
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, projectBuilder,
|
MavenMetadataSource metadataSource = new MavenMetadataSource( projectBuilder, artifactFactory );
|
||||||
artifactFactory );
|
|
||||||
|
|
||||||
String version = null;
|
String version = null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -17,9 +17,9 @@ package org.apache.maven.plugin;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
|
@ -66,7 +66,8 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MavenSession createSession( MavenProject project, PlexusContainer container, ArtifactRepository repo )
|
private static MavenSession createSession( MavenProject project, PlexusContainer container,
|
||||||
|
ArtifactRepository repo )
|
||||||
{
|
{
|
||||||
return new MavenSession( project, container, new Settings(), repo, new DefaultEventDispatcher(),
|
return new MavenSession( project, container, new Settings(), repo, new DefaultEventDispatcher(),
|
||||||
Collections.EMPTY_LIST );
|
Collections.EMPTY_LIST );
|
||||||
|
@ -103,7 +104,7 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
{
|
{
|
||||||
PluginDescriptor pd = new PluginDescriptor();
|
PluginDescriptor pd = new PluginDescriptor();
|
||||||
|
|
||||||
Artifact artifact = new DefaultArtifact( "testGroup", "testArtifact", "1.0", Artifact.SCOPE_COMPILE, "jar", null, null );
|
Artifact artifact = createArtifact( "testGroup", "testArtifact", "1.0" );
|
||||||
|
|
||||||
pd.setArtifacts( Collections.singletonList( artifact ) );
|
pd.setArtifacts( Collections.singletonList( artifact ) );
|
||||||
|
|
||||||
|
@ -138,9 +139,17 @@ public class PluginParameterExpressionEvaluatorTest
|
||||||
PlexusContainer container = getContainer();
|
PlexusContainer container = getContainer();
|
||||||
MavenSession session = createSession( project, container, repo );
|
MavenSession session = createSession( project, container, repo );
|
||||||
|
|
||||||
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, pluginDescriptor,
|
return (ExpressionEvaluator) new PluginParameterExpressionEvaluator( session, pluginDescriptor, null,
|
||||||
null, container.getLogger(),
|
container.getLogger(), project );
|
||||||
project );
|
|
||||||
return expressionEvaluator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Artifact createArtifact( String groupId, String artifactId, String version )
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
|
|
||||||
|
// TODO: used to be SCOPE_COMPILE, check
|
||||||
|
return artifactFactory.createBuildArtifact( groupId, artifactId, version, "jar" );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
package org.apache.maven.usability;
|
package org.apache.maven.usability;
|
||||||
|
|
||||||
import org.apache.maven.artifact.DefaultArtifact;
|
import org.apache.maven.artifact.DefaultArtifact;
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -21,9 +24,8 @@ import junit.framework.TestCase;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class InvalidArtifactDiagnoserTest
|
public class InvalidArtifactDiagnoserTest
|
||||||
extends TestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
private InvalidArtifactDiagnoser diagnoser = new InvalidArtifactDiagnoser();
|
private InvalidArtifactDiagnoser diagnoser = new InvalidArtifactDiagnoser();
|
||||||
|
|
||||||
public void testShouldDiagnoseArtifactWithMissingGroupId() throws Throwable
|
public void testShouldDiagnoseArtifactWithMissingGroupId() throws Throwable
|
||||||
|
@ -61,7 +63,7 @@ public class InvalidArtifactDiagnoserTest
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new DefaultArtifact( groupId, artifactId, version, null, type, null, null );
|
createArtifact( groupId, artifactId, version, type );
|
||||||
|
|
||||||
fail( "artifact creation did not fail; nothing to diagnose." );
|
fail( "artifact creation did not fail; nothing to diagnose." );
|
||||||
}
|
}
|
||||||
|
@ -79,4 +81,12 @@ public class InvalidArtifactDiagnoserTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Artifact createArtifact( String groupId, String artifactId, String version, String type )
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
|
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,24 +16,23 @@ package org.apache.maven.plugin.descriptor;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.ArtifactUtils;
|
||||||
|
import org.apache.maven.plugin.lifecycle.Lifecycle;
|
||||||
|
import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
|
||||||
|
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
|
||||||
|
import org.codehaus.classworlds.ClassRealm;
|
||||||
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
|
import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import org.codehaus.classworlds.ClassRealm;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
|
||||||
import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
|
|
||||||
import org.apache.maven.plugin.lifecycle.Lifecycle;
|
|
||||||
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.DependencyManagement;
|
import org.apache.maven.model.DependencyManagement;
|
||||||
|
@ -120,7 +121,7 @@ public class DefaultMavenProjectBuilder
|
||||||
List externalProfiles )
|
List externalProfiles )
|
||||||
throws ProjectBuildingException, ArtifactResolutionException
|
throws ProjectBuildingException, ArtifactResolutionException
|
||||||
{
|
{
|
||||||
ArtifactMetadataSource source = new MavenMetadataSource( artifactResolver, this, artifactFactory );
|
ArtifactMetadataSource source = new MavenMetadataSource( this, artifactFactory );
|
||||||
return buildWithDependencies( projectDescriptor, localRepository, source, externalProfiles );
|
return buildWithDependencies( projectDescriptor, localRepository, source, externalProfiles );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||||
Artifact projectArtifact = project.getArtifact();
|
Artifact projectArtifact = project.getArtifact();
|
||||||
|
|
||||||
Map managedVersions = createManagedVersionMap( project.getDependencyManagement() );
|
Map managedVersions = createManagedVersionMap( project.getDependencyManagement() );
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
||||||
projectArtifact, managedVersions,
|
projectArtifact, managedVersions,
|
||||||
|
@ -166,8 +167,9 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) i.next();
|
Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||||
d.getScope(), d.getType(), null );
|
new VersionRange( d.getVersion() ),
|
||||||
|
d.getType(), d.getScope() );
|
||||||
|
|
||||||
map.put( d.getManagementKey(), artifact );
|
map.put( d.getManagementKey(), artifact );
|
||||||
}
|
}
|
||||||
|
@ -194,7 +196,8 @@ public class DefaultMavenProjectBuilder
|
||||||
// Always cache files in the source tree over those in the repository
|
// Always cache files in the source tree over those in the repository
|
||||||
modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
|
modelCache.put( createCacheKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ), model );
|
||||||
|
|
||||||
MavenProject project = build( projectDescriptor.getAbsolutePath(), model, localRepository, Collections.EMPTY_LIST, externalProfiles );
|
MavenProject project = build( projectDescriptor.getAbsolutePath(), model, localRepository,
|
||||||
|
Collections.EMPTY_LIST, externalProfiles );
|
||||||
|
|
||||||
// Only translate the base directory for files in the source tree
|
// Only translate the base directory for files in the source tree
|
||||||
pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor );
|
pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor );
|
||||||
|
@ -216,7 +219,8 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||||
|
|
||||||
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories, Collections.EMPTY_LIST );
|
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories,
|
||||||
|
Collections.EMPTY_LIST );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||||
|
@ -274,14 +278,14 @@ public class DefaultMavenProjectBuilder
|
||||||
if ( remoteArtifactRepositories == null || remoteArtifactRepositories.isEmpty() )
|
if ( remoteArtifactRepositories == null || remoteArtifactRepositories.isEmpty() )
|
||||||
{
|
{
|
||||||
aggregatedRemoteWagonRepositories = ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
|
aggregatedRemoteWagonRepositories = ProjectUtils.buildArtifactRepositories( superModel.getRepositories(),
|
||||||
artifactRepositoryFactory,
|
artifactRepositoryFactory,
|
||||||
container );
|
container );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aggregatedRemoteWagonRepositories = remoteArtifactRepositories;
|
aggregatedRemoteWagonRepositories = remoteArtifactRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Iterator i = externalProfiles.iterator(); i.hasNext(); )
|
for ( Iterator i = externalProfiles.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Profile externalProfile = (Profile) i.next();
|
Profile externalProfile = (Profile) i.next();
|
||||||
|
@ -379,16 +383,16 @@ public class DefaultMavenProjectBuilder
|
||||||
project.addProfileProperties( profileProperties );
|
project.addProfileProperties( profileProperties );
|
||||||
|
|
||||||
project.setActiveProfiles( activeProfiles );
|
project.setActiveProfiles( activeProfiles );
|
||||||
|
|
||||||
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
|
// TODO: maybe not strictly correct, while we should enfore that packaging has a type handler of the same id, we don't
|
||||||
Artifact projectArtifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
Artifact projectArtifact = artifactFactory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
|
||||||
project.getVersion(), null, project.getPackaging() );
|
project.getVersion(), project.getPackaging() );
|
||||||
|
|
||||||
project.setArtifact( projectArtifact );
|
project.setArtifact( projectArtifact );
|
||||||
|
|
||||||
project.setPluginArtifactRepositories(
|
project.setPluginArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(),
|
||||||
ProjectUtils.buildArtifactRepositories( model.getPluginRepositories(), artifactRepositoryFactory,
|
artifactRepositoryFactory,
|
||||||
container ) );
|
container ) );
|
||||||
|
|
||||||
DistributionManagement dm = model.getDistributionManagement();
|
DistributionManagement dm = model.getDistributionManagement();
|
||||||
if ( dm != null )
|
if ( dm != null )
|
||||||
|
@ -401,9 +405,9 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( parentProject != null )
|
if ( parentProject != null )
|
||||||
{
|
{
|
||||||
Artifact parentArtifact = artifactFactory.createArtifact( parentProject.getGroupId(),
|
Artifact parentArtifact = artifactFactory.createProjectArtifact( parentProject.getGroupId(),
|
||||||
parentProject.getArtifactId(),
|
parentProject.getArtifactId(),
|
||||||
parentProject.getVersion(), null, "pom" );
|
parentProject.getVersion() );
|
||||||
project.setParentArtifact( parentArtifact );
|
project.setParentArtifact( parentArtifact );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,9 +419,8 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
if ( validationResult.getMessageCount() > 0 )
|
if ( validationResult.getMessageCount() > 0 )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException( "Failed to validate POM for \'" + pomLocation +
|
||||||
"Failed to validate POM for \'" + pomLocation + "\'.\n\n Reason(s):\n" +
|
"\'.\n\n Reason(s):\n" + validationResult.render( " " ) );
|
||||||
validationResult.render( " " ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
|
@ -431,11 +434,11 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
List respositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
|
List respositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
|
||||||
artifactRepositoryFactory, container );
|
artifactRepositoryFactory, container );
|
||||||
|
|
||||||
for ( Iterator it = respositories.iterator(); it.hasNext(); )
|
for ( Iterator it = respositories.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
ArtifactRepository repository = (ArtifactRepository) it.next();
|
ArtifactRepository repository = (ArtifactRepository) it.next();
|
||||||
|
|
||||||
if ( !aggregatedRemoteWagonRepositories.contains( repository ) )
|
if ( !aggregatedRemoteWagonRepositories.contains( repository ) )
|
||||||
{
|
{
|
||||||
aggregatedRemoteWagonRepositories.add( repository );
|
aggregatedRemoteWagonRepositories.add( repository );
|
||||||
|
@ -473,8 +476,9 @@ public class DefaultMavenProjectBuilder
|
||||||
// as we go in order to do this.
|
// as we go in order to do this.
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( parentModel.getGroupId(), parentModel.getArtifactId(),
|
Artifact artifact = artifactFactory.createParentArtifact( parentModel.getGroupId(),
|
||||||
parentModel.getVersion(), null, "pom" );
|
parentModel.getArtifactId(),
|
||||||
|
parentModel.getVersion() );
|
||||||
|
|
||||||
model = findModelFromRepository( artifact, aggregatedRemoteWagonRepositories, localRepository );
|
model = findModelFromRepository( artifact, aggregatedRemoteWagonRepositories, localRepository );
|
||||||
|
|
||||||
|
@ -504,15 +508,13 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException( "Failed to build model from file '" + file.getAbsolutePath() +
|
||||||
"Failed to build model from file '" + file.getAbsolutePath() + "'.\nError: \'" +
|
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
e.getLocalizedMessage() + "\'", e );
|
|
||||||
}
|
}
|
||||||
catch ( XmlPullParserException e )
|
catch ( XmlPullParserException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException( "Failed to parse model from file '" + file.getAbsolutePath() +
|
||||||
"Failed to parse model from file '" + file.getAbsolutePath() + "'.\nError: \'" +
|
"'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
e.getLocalizedMessage() + "\'", e );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -531,15 +533,13 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException( "Failed build model from URL \'" + url.toExternalForm() +
|
||||||
"Failed build model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() +
|
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
"\'", e );
|
|
||||||
}
|
}
|
||||||
catch ( XmlPullParserException e )
|
catch ( XmlPullParserException e )
|
||||||
{
|
{
|
||||||
throw new ProjectBuildingException(
|
throw new ProjectBuildingException( "Failed to parse model from URL \'" + url.toExternalForm() +
|
||||||
"Failed to parse model from URL \'" + url.toExternalForm() + "\'\nError: \'" + e.getLocalizedMessage() +
|
"\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
|
||||||
"\'", e );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -580,8 +580,8 @@ public class DefaultMavenProjectBuilder
|
||||||
version = p.getVersion();
|
version = p.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( p.getGroupId(), p.getArtifactId(), version, null,
|
Artifact artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
|
||||||
"maven-plugin" );
|
new VersionRange( version ) );
|
||||||
if ( artifact != null )
|
if ( artifact != null )
|
||||||
{
|
{
|
||||||
pluginArtifacts.add( artifact );
|
pluginArtifacts.add( artifact );
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.Exclusion;
|
import org.apache.maven.model.Exclusion;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -50,8 +51,7 @@ public class MavenMetadataSource
|
||||||
private ArtifactFactory artifactFactory;
|
private ArtifactFactory artifactFactory;
|
||||||
|
|
||||||
// TODO: Remove resolver from params list.
|
// TODO: Remove resolver from params list.
|
||||||
public MavenMetadataSource( ArtifactResolver artifactResolver, MavenProjectBuilder projectBuilder,
|
public MavenMetadataSource( MavenProjectBuilder projectBuilder, ArtifactFactory artifactFactory )
|
||||||
ArtifactFactory artifactFactory )
|
|
||||||
{
|
{
|
||||||
this.mavenProjectBuilder = projectBuilder;
|
this.mavenProjectBuilder = projectBuilder;
|
||||||
this.artifactFactory = artifactFactory;
|
this.artifactFactory = artifactFactory;
|
||||||
|
@ -61,8 +61,8 @@ public class MavenMetadataSource
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
// TODO: only metadata is really needed - resolve as metadata
|
// TODO: only metadata is really needed - resolve as metadata
|
||||||
Artifact pomArtifact = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
|
Artifact pomArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
|
||||||
artifact.getVersion(), artifact.getScope(), "pom" );
|
artifact.getVersion(), artifact.getScope() );
|
||||||
|
|
||||||
// TODO: this a very thin wrapper around a project builder - is it needed?
|
// TODO: this a very thin wrapper around a project builder - is it needed?
|
||||||
List dependencies = null;
|
List dependencies = null;
|
||||||
|
@ -75,9 +75,10 @@ public class MavenMetadataSource
|
||||||
localRepository );
|
localRepository );
|
||||||
dependencies = p.getDependencies();
|
dependencies = p.getDependencies();
|
||||||
artifact.setDownloadUrl( pomArtifact.getDownloadUrl() );
|
artifact.setDownloadUrl( pomArtifact.getDownloadUrl() );
|
||||||
|
|
||||||
Set artifacts = createArtifacts( artifactFactory, dependencies, artifact.getScope(), artifact.getDependencyFilter() );
|
Set artifacts = createArtifacts( artifactFactory, dependencies, artifact.getScope(),
|
||||||
|
artifact.getDependencyFilter() );
|
||||||
|
|
||||||
return new ResolutionGroup( artifacts, p.getRemoteArtifactRepositories() );
|
return new ResolutionGroup( artifacts, p.getRemoteArtifactRepositories() );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
|
@ -95,8 +96,9 @@ public class MavenMetadataSource
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) i.next();
|
Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||||
d.getScope(), d.getType(), inheritedScope );
|
new VersionRange( d.getVersion() ),
|
||||||
|
d.getType(), d.getScope(), inheritedScope );
|
||||||
|
|
||||||
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
|
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||||
import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
|
import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
import org.apache.maven.artifact.versioning.VersionRange;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||||
|
@ -51,23 +52,28 @@ public class ProjectClasspathArtifactResolver
|
||||||
implements Contextualizable
|
implements Contextualizable
|
||||||
{
|
{
|
||||||
private ArtifactRepositoryFactory repositoryFactory;
|
private ArtifactRepositoryFactory repositoryFactory;
|
||||||
|
|
||||||
private PlexusContainer container;
|
private PlexusContainer container;
|
||||||
|
|
||||||
public static class Source
|
public static class Source
|
||||||
implements ArtifactMetadataSource
|
implements ArtifactMetadataSource
|
||||||
{
|
{
|
||||||
private ArtifactFactory artifactFactory;
|
private ArtifactFactory artifactFactory;
|
||||||
|
|
||||||
private final ArtifactRepositoryFactory repositoryFactory;
|
private final ArtifactRepositoryFactory repositoryFactory;
|
||||||
|
|
||||||
private final PlexusContainer container;
|
private final PlexusContainer container;
|
||||||
|
|
||||||
public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory, PlexusContainer container )
|
public Source( ArtifactFactory artifactFactory, ArtifactRepositoryFactory repositoryFactory,
|
||||||
|
PlexusContainer container )
|
||||||
{
|
{
|
||||||
this.artifactFactory = artifactFactory;
|
this.artifactFactory = artifactFactory;
|
||||||
this.repositoryFactory = repositoryFactory;
|
this.repositoryFactory = repositoryFactory;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
|
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
|
||||||
|
List remoteRepositories )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
Model model = null;
|
Model model = null;
|
||||||
|
@ -101,19 +107,20 @@ public class ProjectClasspathArtifactResolver
|
||||||
{
|
{
|
||||||
IOUtil.close( r );
|
IOUtil.close( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
Set artifacts = createArtifacts( model.getDependencies(), artifact.getScope() );
|
Set artifacts = createArtifacts( model.getDependencies(), artifact.getScope() );
|
||||||
|
|
||||||
List artifactRepositories;
|
List artifactRepositories;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(), repositoryFactory, container );
|
artifactRepositories = ProjectUtils.buildArtifactRepositories( model.getRepositories(),
|
||||||
|
repositoryFactory, container );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( e );
|
throw new ArtifactMetadataRetrievalException( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResolutionGroup( artifacts, artifactRepositories );
|
return new ResolutionGroup( artifacts, artifactRepositories );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +132,10 @@ public class ProjectClasspathArtifactResolver
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) i.next();
|
Dependency d = (Dependency) i.next();
|
||||||
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(),
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||||
d.getScope(), d.getType(), inheritedScope );
|
new VersionRange( d.getVersion() ),
|
||||||
|
d.getType(), d.getScope(),
|
||||||
|
inheritedScope );
|
||||||
if ( artifact != null )
|
if ( artifact != null )
|
||||||
{
|
{
|
||||||
projectArtifacts.add( artifact );
|
projectArtifacts.add( artifact );
|
||||||
|
@ -136,7 +145,7 @@ public class ProjectClasspathArtifactResolver
|
||||||
return projectArtifacts;
|
return projectArtifacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue