Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6373

Despite inherited=false, plugin version and dependencies are inherited

    XMLWordPrintableJSON

    Details

      Description

      There seems to be an issue with skipping plugin inheritance. If the documentation is right, build plugin with property <inherited>false</inherited> should not be inherited in child projects.

      This is inconsistent with observed behavior. Having POM inheritance chain of 3 projects (let's name them uber-parent, parent and child) and build plugin definition in uber-parent marked with inherited=false, the plugin's version and dependencies are still inherited in child projects.

      The behavior was reproduced on versions 3.1.0, 3.2.1, 3.5.0, 3.5.3.

      Steps to reproduce

      This is an example of the weird behavior. Problem can be seen in effective POM for either parent or child project.

      Here are three POM definitions inheriting each other:

      Uber-parent pom.xml

      <project>
          <modelVersion>4.0.0</modelVersion>
      
          <groupId>com.example</groupId>
          <artifactId>uber-parent</artifactId>
          <version>1.0-SNAPSHOT</version>
          <packaging>pom</packaging>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.codehaus.gmavenplus</groupId>
                      <artifactId>gmavenplus-plugin</artifactId>
                      <version>1.1</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>execute</goal>
                              </goals>
                              <phase>test</phase>
                          </execution>
                      </executions>
                      <configuration>
                          <scripts>
                              <script>file:///${project.basedir}/src/main/groovyScripts/generateBomPropertiesFile.groovy</script>
                          </scripts>
                      </configuration>
                      <dependencies>
                          <dependency>
                              <groupId>org.codehaus.groovy</groupId>
                              <artifactId>groovy-all</artifactId>
                              <version>2.3.0</version>
                          </dependency>
                      </dependencies>
                      <inherited>false</inherited>
                  </plugin>
              </plugins>
          </build>
      </project>
      

      Parent pom.xml

      <project>
          <modelVersion>4.0.0</modelVersion>
      
          <parent>
              <groupId>com.example</groupId>
              <artifactId>uber-parent</artifactId>
              <version>1.0-SNAPSHOT</version>
          </parent>
      
          <artifactId>parent</artifactId>
          <packaging>pom</packaging>
      
          <build>
              <pluginManagement>
                  <plugins>
                      <plugin>
                          <groupId>org.codehaus.gmavenplus</groupId>
                          <artifactId>gmavenplus-plugin</artifactId>
                          <version>1.6</version>
                          <executions>
                              <execution>
                                  <goals>
                                      <goal>compileTests</goal>
                                  </goals>
                              </execution>
                          </executions>
                          <dependencies>
                              <dependency>
                                  <groupId>org.codehaus.groovy</groupId>
                                  <artifactId>groovy-all</artifactId>
                                  <version>2.4.14</version>
                              </dependency>
                          </dependencies>
                      </plugin>
                  </plugins>
              </pluginManagement>
              <plugins>
                  <plugin>
                      <groupId>org.codehaus.gmavenplus</groupId>
                      <artifactId>gmavenplus-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
      </project>
      

      Child pom.xml

      <project>
          <modelVersion>4.0.0</modelVersion>
      
          <parent>
              <groupId>com.example</groupId>
              <artifactId>parent</artifactId>
              <version>1.0-SNAPSHOT</version>
          </parent>
      
          <artifactId>child</artifactId>
          <packaging>jar</packaging>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.codehaus.gmavenplus</groupId>
                      <artifactId>gmavenplus-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
      </project>
      

      Excerpt from effective POM for either parent or child project

      <pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <goals>
                  <goal>compileTests</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>2.4.14</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.codehaus.gmavenplus</groupId>
          <artifactId>gmavenplus-plugin</artifactId>
          <version>1.1</version>
          <executions>
            <execution>
              <goals>
                <goal>compileTests</goal>
              </goals>
            </execution>
          </executions>
          <dependencies>
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-all</artifactId>
              <version>2.3.0</version>
              <scope>compile</scope>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Marcin Zarębski Marcin Zarębski
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: