From 727c669350430a5d594af9355817c97a16343a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sun, 23 May 2021 10:23:46 +0200 Subject: [PATCH] [MDEP-749] improve include/exclude scope documentation --- .../AbstractDependencyFilterMojo.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java index 9d6634998..d7ac2997c 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/AbstractDependencyFilterMojo.java @@ -122,14 +122,15 @@ public abstract class AbstractDependencyFilterMojo protected String excludeTypes; /** - * Scope to include. An Empty string indicates all scopes (default). The scopes being interpreted are the scopes as - * Maven sees them, not as specified in the pom. In summary: + * Scope to include. An empty string indicates include all dependencies (default).
+ * The selected scope value being interpreted is the scope as + * Maven filters for creating a classpath, not as specified in the pom. In summary: * * * @since 2.0 @@ -138,15 +139,16 @@ public abstract class AbstractDependencyFilterMojo protected String includeScope; /** - * Scope to exclude. An Empty string indicates no scopes (default). The scopes being interpreted are the scopes as - * Maven sees them, not as specified in the pom. In summary: + * Scope to exclude. An empty string indicates no dependencies (default).
+ * The selected scope value being interpreted is the scope as + * Maven filters for creating a classpath, not as specified in the pom. In summary: * * * @since 2.0 @@ -294,6 +296,12 @@ protected DependencyStatusSets getDependencySets( boolean stopOnFailure, boolean filter.addFilter( new ProjectTransitivityFilter( getProject().getDependencyArtifacts(), this.excludeTransitive ) ); + if ( "test".equals( this.excludeScope ) ) + { + throw new MojoExecutionException( "Excluding every artifact inside 'test' resolution scope means " + + "excluding everything: you probably want includeScope='compile', " + + "read parameters documentation for detailed explanations" ); + } filter.addFilter( new ScopeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeScope ), DependencyUtil.cleanToBeTokenizedString( this.excludeScope ) ) );