diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java b/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java similarity index 100% rename from maven-compat/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java rename to maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultArtifactFactory.java diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java index 2fa0734a32..75286e54d3 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java @@ -18,14 +18,15 @@ package org.apache.maven.lifecycle.internal; import org.apache.maven.ProjectDependenciesResolver; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.MavenExecutionPlan; -import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; @@ -50,6 +51,9 @@ public class LifecycleDependencyResolver @Requirement private Logger logger; + @Requirement + private ArtifactFactory artifactFactory; + @SuppressWarnings({"UnusedDeclaration"}) public LifecycleDependencyResolver() { @@ -117,16 +121,19 @@ public class LifecycleDependencyResolver Set artifacts = getProjectDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, projectArtifacts ); - updateProjectArtifacts( project, artifacts ); - } - private void updateProjectArtifacts( MavenProject project, Set artifacts ) - { project.setResolvedArtifacts( artifacts ); if ( project.getDependencyArtifacts() == null ) { - project.setDependencyArtifacts( getDependencyArtifacts( project, artifacts ) ); + try + { + project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) ); + } + catch ( InvalidDependencyVersionException e ) + { + throw new LifecycleExecutionException( e ); + } } } @@ -197,25 +204,6 @@ public class LifecycleDependencyResolver return artifacts; } - private Set getDependencyArtifacts( MavenProject project, Set artifacts ) - { - Set directDependencies = new HashSet( project.getDependencies().size() * 2 ); - for ( Dependency dependency : project.getDependencies() ) - { - directDependencies.add( dependency.getManagementKey() ); - } - - Set dependencyArtifacts = new LinkedHashSet( project.getDependencies().size() * 2 ); - for ( Artifact artifact : artifacts ) - { - if ( directDependencies.contains( artifact.getDependencyConflictId() ) ) - { - dependencyArtifacts.add( artifact ); - } - } - return dependencyArtifacts; - } - private boolean areAllArtifactsInReactor( Collection projects, Collection artifacts ) { Set projectKeys = getReactorProjectKeys( projects );