You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2021/05/23 08:23:49 UTC

[maven-dependency-plugin] branch master updated: [MDEP-749] improve include/exclude scope documentation

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 727c669  [MDEP-749] improve include/exclude scope documentation
727c669 is described below

commit 727c669350430a5d594af9355817c97a16343a7d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun May 23 10:23:46 2021 +0200

    [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 9d66349..d7ac299 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).<br>
+     * The selected scope value being interpreted is the scope as
+     * Maven filters for creating a classpath, not as specified in the pom. In summary:
      * <ul>
-     * <li><code>runtime</code> scope gives runtime and compile dependencies,</li>
-     * <li><code>compile</code> scope gives compile, provided, and system dependencies,</li>
-     * <li><code>test</code> (default) scope gives all dependencies,</li>
-     * <li><code>provided</code> scope just gives provided dependencies,</li>
-     * <li><code>system</code> scope just gives system dependencies.</li>
+     * <li><code>runtime</code> include scope gives runtime and compile dependencies,</li>
+     * <li><code>compile</code> include scope gives compile, provided, and system dependencies,</li>
+     * <li><code>test</code> include scope gives all dependencies (equivalent to default),</li>
+     * <li><code>provided</code> include scope just gives provided dependencies,</li>
+     * <li><code>system</code> include scope just gives system dependencies.</li>
      * </ul>
      *
      * @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).<br>
+     * The selected scope value being interpreted is the scope as
+     * Maven filters for creating a classpath, not as specified in the pom. In summary:
      * <ul>
-     * <li><code>runtime</code> scope excludes runtime and compile dependencies,</li>
-     * <li><code>compile</code> scope excludes compile, provided, and system dependencies,</li>
-     * <li><code>test</code> scope excludes all dependencies, then not really a legitimate option: it will fail,
-     * you probably meant to configure includeScope = compile or runtime</li>
-     * <li><code>provided</code> scope just excludes provided dependencies,</li>
-     * <li><code>system</code> scope just excludes system dependencies.</li>
+     * <li><code>runtime</code> exclude scope excludes runtime and compile dependencies,</li>
+     * <li><code>compile</code> exclude scope excludes compile, provided, and system dependencies,</li>
+     * <li><code>test</code> exclude scope excludes all dependencies, then not really a legitimate option: it will
+     * fail, you probably meant to configure includeScope = compile</li>
+     * <li><code>provided</code> exclude scope just excludes provided dependencies,</li>
+     * <li><code>system</code> exclude scope just excludes system dependencies.</li>
      * </ul>
      *
      * @since 2.0
@@ -294,6 +296,12 @@ public abstract class AbstractDependencyFilterMojo
         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 ) ) );