diff --git a/pom.xml b/pom.xml
index 13cbf09b86..931f1f1842 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,6 +89,7 @@ under the License.
+ true
3.1.1
1.9.1
1.9.2
@@ -96,10 +97,40 @@ under the License.
3.1.0
7
2020-03-07T11:40:47Z
+ 1.8
+ 1.3.1
+ org.junit.platform:junit-platform-engine
+
+
+ org.apache.maven.surefire
+ surefire-api
+
+ 2.9
+
+
+ org.apache.maven.surefire
+ maven-surefire-common
+ 2.22.1
+
+
+ org.apache.maven.surefire
+ surefire-booter
+ 2.22.1
+
+
+ org.apache.maven.shared
+ maven-common-artifact-filters
+ 3.0.1
+
+
+ org.eclipse.aether
+ aether-api
+ 1.1.0
+
org.ow2.asm
asm
@@ -109,7 +140,33 @@ under the License.
-
+
+ org.apache.maven.surefire
+ surefire-api
+
+ 2.9
+
+
+ org.apache.maven.surefire
+ surefire-booter
+ 2.22.1
+
+
+ org.apache.maven.surefire
+ maven-surefire-common
+ 2.22.1
+
+
+ org.apache.maven.shared
+ maven-common-artifact-filters
+ 3.0.1
+
+
+
+ org.eclipse.aether
+ aether-api
+ 1.1.0
+
org.apache.maven
@@ -226,7 +283,7 @@ under the License.
org.apache.maven.shared
maven-common-artifact-filters
- 3.1.0
+ 3.0.1
org.apache.maven.shared
@@ -354,6 +411,7 @@ under the License.
These files contain results for integration tests which can't contain license header
otherwise the IT's will fail.
-->
+ surefire/*
src/it/projects/tree/expected.txt
src/it/projects/tree-includes/expected.txt
src/it/projects/tree-multimodule/expected.txt
@@ -371,6 +429,27 @@ under the License.
+
+ org.apache.maven.plugins
+ maven-plugin-plugin
+
+
+
+
+
+
+
+ true
+
+
+
+ mojo-descriptor
+
+ descriptor
+
+
+
+
org.apache.maven.plugins
maven-enforcer-plugin
@@ -396,8 +475,43 @@ under the License.
org.apache.maven.plugins
maven-surefire-plugin
+ 2.22.1
+
+
+ org.apache.maven.surefire
+ surefire-api
+
+ 2.9
+
+
+ org.apache.maven.surefire
+ surefire-booter
+ 2.22.1
+
+
+ org.apache.maven.surefire
+ maven-surefire-common
+ 2.22.1
+
+
+ org.apache.maven.shared
+ maven-common-artifact-filters
+ 3.0.1
+
+
+ org.apache.maven.shared
+ maven-shared-utils
+ 3.2.1
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.3.2
+
+
+ org.junit.platform:junit-platform-engine
-Xmx384m
${maven.home}
@@ -412,6 +526,7 @@ under the License.
run-its
+
tree-verbose/pom.xml
*/pom.xml
purge-local-repository-without-pom
-
src/it/mrm/settings.xml
${repository.proxy.url}
+ -->
+
+
+ -->
@@ -471,6 +587,7 @@ under the License.
reporting
+
diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
index b41a4289bd..3417fbdb09 100644
--- a/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
+++ b/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
@@ -20,14 +20,20 @@
*/
import java.io.File;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
+import javax.inject.Inject;
+
+import org.apache.maven.ProjectDependenciesResolver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
-import org.apache.maven.model.Dependency;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
@@ -35,7 +41,6 @@
import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
import org.apache.maven.plugins.dependency.utils.DependencyUtil;
import org.apache.maven.plugins.dependency.utils.filters.ArtifactItemFilter;
-import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
@@ -270,33 +275,31 @@ protected Artifact getArtifact( ArtifactItem artifactItem )
private void fillMissingArtifactVersion( ArtifactItem artifact )
throws MojoExecutionException
{
- MavenProject project = getProject();
- List deps = project.getDependencies();
- List depMngt = project.getDependencyManagement() == null ? Collections.emptyList()
- : project.getDependencyManagement().getDependencies();
-
- if ( !findDependencyVersion( artifact, deps, false )
- && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, false ) )
- && !findDependencyVersion( artifact, deps, true )
- && ( project.getDependencyManagement() == null || !findDependencyVersion( artifact, depMngt, true ) ) )
+ try
+ {
+ if ( !this.findDependencyVersion( artifact, false ) && !this.findDependencyVersion( artifact, true ) )
+ {
+ throw new MojoExecutionException( "Unable to find artifact version of " + artifact.getGroupId() + ":"
+ + artifact.getArtifactId() + " in transitively resolved dependencies." );
+ }
+ }
+ catch ( final ArtifactResolutionException | ArtifactNotFoundException e )
{
- throw new MojoExecutionException( "Unable to find artifact version of " + artifact.getGroupId() + ":"
- + artifact.getArtifactId() + " in either dependency list or in project's dependency management." );
+ throw new MojoExecutionException( "Failed to transitively resolve project dependencies.", e );
}
}
- /**
- * Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct
- * version.
- *
- * @param artifact representing configured file.
- * @param dependencies list of dependencies to search.
- * @param looseMatch only look at artifactId and groupId
- * @return the found dependency
- */
- private boolean findDependencyVersion( ArtifactItem artifact, List dependencies, boolean looseMatch )
+ @Inject
+ private ProjectDependenciesResolver resolver;
+
+ private boolean findDependencyVersion( final ArtifactItem artifact, boolean looseMatch )
+ throws ArtifactResolutionException, ArtifactNotFoundException
{
- for ( Dependency dependency : dependencies )
+ final Set resolvedArtifacts =
+ this.resolver.resolve( this.getProject(),
+ Arrays.asList( "compile", "provided", "runtime", "test", "system", "import" ),
+ this.session );
+ for ( final Artifact dependency : resolvedArtifacts )
{
if ( Objects.equals( dependency.getArtifactId(), artifact.getArtifactId() )
&& Objects.equals( dependency.getGroupId(), artifact.getGroupId() )