Omit test scope from copyDependencies when version parameter is null
@@ -226,6 +226,7 @@ public abstract class AbstractLibertySupport extends MojoSupport {
/**
* Find resolved dependencies with matching groupId:artifactId:version. Also collect transitive dependencies for those
* resolved dependencies. The groupId is required. The artifactId and version are optional.
+ * If version is null, then test scoped dependencies are omitted.
* The artifactId can also end with a '*' to indicate a wildcard match.
*
* @param groupId String specifying the groupId of the Maven artifact to copy.
@@ -298,6 +299,15 @@ public abstract class AbstractLibertySupport extends MojoSupport {
}
}
+ // Remove test scoped dependencies
+ Set<Artifact> dependenciesWithoutTest = new HashSet<Artifact>();
+ for (Artifact artifact : resolvedDependencies) {
+ if (!"test".equals(artifact.getScope())) {
+ dependenciesWithoutTest.add(artifact);
+ }
+ }
+ resolvedDependencies = dependenciesWithoutTest;
+
if (resolvedDependencies.isEmpty()) {
// No matching artifacts were found in the resolved dependencies. Send warning.
log.warn("Unable to find artifact matching groupId "+ groupId +", artifactId "+artifactId+", and version "+version+" in either project dependencies or in project dependencyManagement.");
