You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ma...@apache.org on 2021/03/22 12:16:53 UTC

[maven] branch master updated: [MNG-7102] The child modules of excluded projects are now excluded as well, making the behavior consistent with MNG-6981.

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

martinkanters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new a028346  [MNG-7102] The child modules of excluded projects are now excluded as well, making the behavior consistent with MNG-6981.
a028346 is described below

commit a02834611bad3442ad073b10f1dee2322916f1f3
Author: Martin Kanters <ma...@apache.org>
AuthorDate: Sat Feb 20 11:37:17 2021 +0100

    [MNG-7102] The child modules of excluded projects are now excluded as well, making the behavior consistent with MNG-6981.
---
 .../java/org/apache/maven/graph/DefaultGraphBuilder.java     | 12 +++++++++++-
 .../java/org/apache/maven/graph/DefaultGraphBuilderTest.java |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
index 797cbe2..49d52af 100644
--- a/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
+++ b/maven-core/src/main/java/org/apache/maven/graph/DefaultGraphBuilder.java
@@ -255,7 +255,17 @@ public class DefaultGraphBuilder
                         .findFirst()
                         .orElseThrow( () -> new MavenExecutionException( "Could not find the selected project in "
                                 + "the reactor: " + selector, request.getPom() ) );
-                result.remove( excludedProject );
+
+                boolean isExcludedProjectRemoved = result.remove( excludedProject );
+
+                if ( isExcludedProjectRemoved )
+                {
+                    List<MavenProject> children = excludedProject.getCollectedProjects();
+                    if ( children != null )
+                    {
+                        result.removeAll( children );
+                    }
+                }
             }
         }
 
diff --git a/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java b/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
index 4a8f9c0..e82c735 100644
--- a/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
+++ b/maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
@@ -147,6 +147,9 @@ public class DefaultGraphBuilderTest
                         .excludedProjects( MODULE_B )
                         .makeBehavior( REACTOR_MAKE_UPSTREAM )
                         .expectResult( PARENT_MODULE, MODULE_C, MODULE_A, MODULE_C_2 ),
+                scenario( "Excluding a project also excludes its children" )
+                        .excludedProjects( MODULE_C )
+                        .expectResult( PARENT_MODULE, MODULE_A, MODULE_B, INDEPENDENT_MODULE ),
                 scenario( "Excluding an also make dependency from resumeFrom does take its transitive dependency" )
                         .resumeFrom( MODULE_C_2 )
                         .excludedProjects( MODULE_B )