You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/05/21 20:19:25 UTC

svn commit: r777205 - in /maven/components/branches/MNG-2766: maven-core/src/test/java/org/apache/maven/project/ maven-core/src/test/resources-project-builder/plugin-exec-inheritance/ maven-core/src/test/resources-project-builder/plugin-exec-inheritanc...

Author: bentmann
Date: Thu May 21 18:19:22 2009
New Revision: 777205

URL: http://svn.apache.org/viewvc?rev=777205&view=rev
Log:
[MNG-4129] Execution's inherited is not working as expected.

Added:
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/   (with props)
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml   (with props)
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/   (with props)
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml   (with props)
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/   (with props)
    maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml   (with props)
Modified:
    maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
    maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java

Modified: maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=777205&r1=777204&r2=777205&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java Thu May 21 18:19:22 2009
@@ -27,6 +27,7 @@
 
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.model.PluginExecution;
 import org.apache.maven.project.harness.PomTestWrapper;
 import org.codehaus.plexus.PlexusTestCase;
 
@@ -1437,6 +1438,27 @@
         assertEquals( "PASSED", pom.getValue( "name" ) );
     }    
 
+    /* MNG-4129 */
+    public void testPluginExecutionInheritanceWhenChildDoesNotDeclarePlugin()
+        throws Exception
+    {
+        PomTestWrapper pom = buildPom( "plugin-exec-inheritance/wo-merge" );
+        List<PluginExecution> executions =
+            (List<PluginExecution>) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" );
+        assertEquals( 1, executions.size() );
+        assertEquals( "inherited-execution", executions.get( 0 ).getId() );
+    }
+
+    public void testPluginExecutionInheritanceWhenChildDoesDeclarePluginAsWell()
+        throws Exception
+    {
+        PomTestWrapper pom = buildPom( "plugin-exec-inheritance/w-merge" );
+        List<PluginExecution> executions =
+            (List<PluginExecution>) pom.getValue( "build/pluginsAsMap[@name='org.apache.maven.its.plugins:maven-it-plugin-log-file']/executions" );
+        assertEquals( 1, executions.size() );
+        assertEquals( "inherited-execution", executions.get( 0 ).getId() );
+    }    
+
     private void assertPathSuffixEquals( String expected, Object actual )
     {
         String a = actual.toString();

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml?rev=777205&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml (added)
+++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml Thu May 21 18:19:22 2009
@@ -0,0 +1,75 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mng4129</groupId>
+  <artifactId>parent</artifactId>
+  <version>0.1</version>
+  <packaging>pom</packaging>
+
+  <name>Maven Integration Test :: MNG-4129</name>
+  <description>
+    Verify that plugin executions defined in the parent with inherited=false are not executed in child modules.
+  </description>
+
+  <modules>
+    <module>child-1</module>
+    <module>child-2</module>
+  </modules>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-log-file</artifactId>
+        <version>2.1-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>inherited-execution</id>
+            <inherited>true</inherited>
+            <phase>validate</phase>
+            <goals>
+              <goal>log-string</goal>
+            </goals>
+            <configuration>
+              <logFile>target/executions.txt</logFile>
+              <string>inherited-execution</string>
+            </configuration>
+          </execution>
+          <execution>
+            <id>non-inherited-execution</id>
+            <inherited>false</inherited>
+            <phase>validate</phase>
+            <goals>
+              <goal>log-string</goal>
+            </goals>
+            <configuration>
+              <logFile>target/executions.txt</logFile>
+              <string>non-inherited-execution</string>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml?rev=777205&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml (added)
+++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml Thu May 21 18:19:22 2009
@@ -0,0 +1,48 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng4129</groupId>
+    <artifactId>parent</artifactId>
+    <version>0.1</version>
+  </parent>
+
+  <artifactId>child-1</artifactId>
+
+  <name>Maven Integration Test :: MNG-4129 :: Child-1</name>
+  <description>
+    Verify that plugin executions defined in the parent with inherited=false are not executed in child modules.
+  </description>
+
+  <build>
+    <plugins>
+      <!-- NOTE: It's essential part of this test variant to redefine the test plugin again, i.e. trigger plugin merging -->
+      <plugin>
+        <groupId>org.apache.maven.its.plugins</groupId>
+        <artifactId>maven-it-plugin-log-file</artifactId>
+        <version>2.1-SNAPSHOT</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/w-merge/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/
------------------------------------------------------------------------------
    bugtraq:label = Enter issue ID:

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/
------------------------------------------------------------------------------
    bugtraq:message = Issue id: %BUGID%

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/
------------------------------------------------------------------------------
    bugtraq:number = false

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml?rev=777205&view=auto
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml (added)
+++ maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml Thu May 21 18:19:22 2009
@@ -0,0 +1,43 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mng4129</groupId>
+    <artifactId>parent</artifactId>
+    <version>0.1</version>
+  </parent>
+
+  <artifactId>child-2</artifactId>
+
+  <name>Maven Integration Test :: MNG-4129 :: Child-2</name>
+  <description>
+    Verify that plugin executions defined in the parent with inherited=false are not executed in child modules.
+  </description>
+
+  <build>
+    <plugins>
+      <!-- NOTE: It's essential part of this test variant to *not* define the test plugin again, i.e. bypass plugin merging -->
+    </plugins>
+  </build>
+</project>

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/MNG-2766/maven-core/src/test/resources-project-builder/plugin-exec-inheritance/wo-merge/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java?rev=777205&r1=777204&r2=777205&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java (original)
+++ maven/components/branches/MNG-2766/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java Thu May 21 18:19:22 2009
@@ -412,14 +412,15 @@
                 Plugin element = it.next();
                 Object key = getPluginKey( element );
                 Plugin existing = merged.get( key );
-                if ( existing != null )
-                {
-                    mergePlugin( existing, element, sourceDominant, context );
-                }
-                else
+                if ( existing == null )
                 {
-                    merged.put( key, element );
+                    // NOTE: Enforce recursive merge to trigger merging/inheritance logic for executions as well
+                    existing = new Plugin();
+                    existing.setGroupId( element.getGroupId() );
+                    existing.setArtifactId( element.getArtifactId() );
+                    merged.put( key, existing );
                 }
+                mergePlugin( existing, element, sourceDominant, context );
             }
 
             target.setPlugins( new ArrayList<Plugin>( merged.values() ) );
@@ -449,14 +450,15 @@
                 ReportPlugin element = it.next();
                 Object key = getReportPluginKey( element );
                 ReportPlugin existing = merged.get( key );
-                if ( existing != null )
-                {
-                    mergeReportPlugin( existing, element, sourceDominant, context );
-                }
-                else
+                if ( existing == null )
                 {
-                    merged.put( key, element );
+                    // NOTE: Enforce recursive merge to trigger merging/inheritance logic for executions as well
+                    existing = new ReportPlugin();
+                    existing.setGroupId( element.getGroupId() );
+                    existing.setArtifactId( element.getArtifactId() );
+                    merged.put( key, existing );
                 }
+                mergeReportPlugin( existing, element, sourceDominant, context );
             }
 
             target.setPlugins( new ArrayList<ReportPlugin>( merged.values() ) );