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

gnodet pushed a commit to branch maven-3.10.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.10.x by this push:
     new 29323235b4 Respect plugin-level inherited=false when the plugin has 
executions (fixes #7476) (#13952)
29323235b4 is described below

commit 29323235b4ea769062d0d29f4e61d3060859af54
Author: Arturo Bernal <[email protected]>
AuthorDate: Fri Nov 13 09:27:43 2026 +0100

    Respect plugin-level inherited=false when the plugin has executions (fixes 
#7476) (#13952)
    
    * [MNG-6373] Respect plugin-level inherited=false when the plugin has 
executions
    
    DefaultInheritanceAssembler.mergePluginContainer_Plugins() decided
    whether a parent build plugin participates in inheritance with:
    
      element.isInherited() || !element.getExecutions().isEmpty()
    
    so any parent plugin declaring at least one <execution> was folded
    into the child's effective plugin set regardless of an explicit
    <inherited>false</inherited> - exactly the kind of plugin declaration
    for which that flag matters most in practice. Since the default value
    of isInherited() is already true, the extra executions clause only
    ever changed the outcome for plugins explicitly marked non-inherited,
    silently overriding them.
    
    Drop the executions override so a plugin's own inherited flag is the
    only thing that decides whether it reaches child POMs.
    
    Fixes #7476
    
    * Preserve the MNG-2103 execution-level inherited override
    
    The previous commit gated the whole plugin on its own inherited flag,
    which also dropped plugins that rely on MNG-2103's documented escape
    hatch: an execution with its own <inherited>true</inherited> must
    still reach the child even when the plugin itself is marked
    inherited=false. CI caught this via
    MavenITmng2103PluginExecutionInheritanceTest.
    
    Only commit the merged plugin to the inherited set once we know
    whether any of its executions actually survived the per-execution
    inherited filtering - if none did, the plugin itself must not be
    inherited either (MNG-6373); if at least one did, the whole plugin,
    including that surviving execution, must flow through (MNG-2103).
    
    Added a regression test for the execution-override case alongside
    the existing MNG-6373 one.
---
 .../inheritance/DefaultInheritanceAssembler.java   | 12 +++--
 .../DefaultInheritanceAssemblerTest.java           | 20 +++++++
 .../inheritance/plugin-not-inherited-child.xml     | 28 ++++++++++
 ...ugin-not-inherited-execution-override-child.xml | 28 ++++++++++
 ...n-not-inherited-execution-override-expected.xml | 52 ++++++++++++++++++
 ...gin-not-inherited-execution-override-parent.xml | 58 ++++++++++++++++++++
 .../inheritance/plugin-not-inherited-expected.xml  | 49 +++++++++++++++++
 .../inheritance/plugin-not-inherited-parent.xml    | 63 ++++++++++++++++++++++
 8 files changed, 307 insertions(+), 3 deletions(-)

diff --git 
a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
 
b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
index e29444e41f..ade9c839e8 100644
--- 
a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
+++ 
b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java
@@ -228,9 +228,15 @@ protected void mergePluginContainer_Plugins(
                         plugin.setGroupId(null);
                         mergePlugin(plugin, element, sourceDominant, context);
 
-                        Object key = getPluginKey(element);
-
-                        master.put(key, plugin);
+                        // a plugin marked inherited=false only reaches the 
child through an execution
+                        // whose own inherited flag overrides the plugin-level 
setting (MNG-2103); if no
+                        // execution survives that per-execution filtering, 
the plugin itself must not be
+                        // inherited either (MNG-6373), so only commit it once 
we know which case applies
+                        if (element.isInherited() || 
!plugin.getExecutions().isEmpty()) {
+                            Object key = getPluginKey(element);
+
+                            master.put(key, plugin);
+                        }
                     }
                 }
 
diff --git 
a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
 
b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
index e67b85114c..50494035c2 100644
--- 
a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
+++ 
b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java
@@ -66,6 +66,26 @@ public void testPluginConfiguration() throws Exception {
         testInheritance("plugin-configuration");
     }
 
+    /**
+     * MNG-6373: a build plugin marked {@code inherited=false} must not reach 
child POMs,
+     * even when it declares an execution.
+     * @throws Exception
+     */
+    @Test
+    public void testPluginNotInherited() throws Exception {
+        testInheritance("plugin-not-inherited");
+    }
+
+    /**
+     * MNG-2103: an execution's own {@code inherited=true} overrides a 
plugin-level
+     * {@code inherited=false}, so the whole plugin must still reach the child.
+     * @throws Exception
+     */
+    @Test
+    public void testPluginNotInheritedWithInheritedExecutionOverride() throws 
Exception {
+        testInheritance("plugin-not-inherited-execution-override");
+    }
+
     /**
      * Check most classical urls inheritance: directory structure where parent 
POM in parent directory
      * and child directory == artifactId
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-child.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-child.xml
new file mode 100644
index 0000000000..6ddc5757ac
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-child.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>child</artifactId>
+  <version>1-SNAPSHOT</version>
+</project>
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-child.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-child.xml
new file mode 100644
index 0000000000..6ddc5757ac
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-child.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>child</artifactId>
+  <version>1-SNAPSHOT</version>
+</project>
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-expected.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-expected.xml
new file mode 100644
index 0000000000..6e2b31ce85
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-expected.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>inheritance</groupId>
+  <artifactId>child</artifactId>
+  <version>1-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <!-- MNG-2103: the plugin itself (version, identity) still reaches the 
child because
+           one of its executions carries its own inherited=true override; the 
other
+           execution (no override, falls back to the plugin-level 
inherited=false) is
+           correctly filtered out -->
+      <plugin>
+        <groupId>inheritance.plugin</groupId>
+        <artifactId>overridden</artifactId>
+        <version>1.0</version>
+        <executions>
+          <execution>
+            <id>inherited-execution</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <inherited>true</inherited>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-parent.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-parent.xml
new file mode 100644
index 0000000000..d965becc24
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-execution-override-parent.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>inheritance</groupId>
+  <artifactId>parent</artifactId>
+  <version>1-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <!-- MNG-2103: an execution with its own inherited=true overrides a 
plugin-level
+             inherited=false, so the whole plugin (including this execution) 
must still
+             reach the child -->
+        <groupId>inheritance.plugin</groupId>
+        <artifactId>overridden</artifactId>
+        <version>1.0</version>
+        <inherited>false</inherited>
+        <executions>
+          <execution>
+            <id>inherited-execution</id>
+            <inherited>true</inherited>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>not-inherited-execution</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-expected.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-expected.xml
new file mode 100644
index 0000000000..cb8a68d644
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-expected.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>inheritance</groupId>
+  <artifactId>child</artifactId>
+  <version>1-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <!-- MNG-6373: the parent's "not-inherited" plugin (inherited=false) 
must not appear here,
+           even though it declares an execution -->
+      <plugin>
+        <groupId>inheritance.plugin</groupId>
+        <artifactId>inherited</artifactId>
+        <version>2.0</version>
+        <executions>
+          <execution>
+            <id>inherited-execution</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git 
a/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-parent.xml
 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-parent.xml
new file mode 100644
index 0000000000..a76f869e98
--- /dev/null
+++ 
b/maven-model-builder/src/test/resources/poms/inheritance/plugin-not-inherited-parent.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>inheritance</groupId>
+  <artifactId>parent</artifactId>
+  <version>1-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <!-- MNG-6373: a plugin marked inherited=false must not reach child 
POMs,
+             even though it declares an execution -->
+        <groupId>inheritance.plugin</groupId>
+        <artifactId>not-inherited</artifactId>
+        <version>1.0</version>
+        <inherited>false</inherited>
+        <executions>
+          <execution>
+            <id>not-inherited-execution</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>inheritance.plugin</groupId>
+        <artifactId>inherited</artifactId>
+        <version>2.0</version>
+        <executions>
+          <execution>
+            <id>inherited-execution</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Reply via email to