Package: maven-repo-helper
Version: 1.8.12
Severity: normal

maven-repo-helper doesn't transform properly the plugin dependencies
when a plugin is ignored.

For example with this declaration:

    <plugin>
      <groupId>foo</groupId>
      <artifactId>foo</artifactId>
      <dependencies>
        <dependency>
          <groupId>foo-dep</groupId>
          <artifactId>foo-dep</artifactId>
          <version>1.0</version>
        </dependency>
      </dependencies>
    </plugin>
    <plugin>
      <groupId>bar</groupId>
      <artifactId>bar</artifactId>
      <dependencies>
        <dependency>
          <groupId>bar-dep</groupId>
          <artifactId>bar-dep</artifactId>
          <version>2.0</version>
        </dependency>
      </dependencies>
    </plugin>

Ignoring the plugin foo will result in this transformed pom:

    <plugin>
      <groupId>bar</groupId>
      <artifactId>bar</artifactId>
      <dependencies>
        <dependency>
          <groupId>foo-dep</groupId>
          <artifactId>foo-dep</artifactId>
          <version>1.0</version>
        </dependency>
      </dependencies>
    </plugin>

The dependencies of the ignored plugins are shifted and go to the next
plugin with dependencies instead of being ignored.

It's possible to reproduce this issue with the following test case
applied to the hibernate-validator-parent 4.3.2 pom:

    @Test
    public void testTransformPluginDependencies() throws Exception {
        File pom = tmpDir.usePom("hibernate-validator-parent-4.3.2.Final.pom");
        instance.getRulesFiles().addDefaultRules();
        instance.getRulesFiles().get(IGNORE).add(new 
DependencyRule("org.jboss.maven.plugins maven-jdocbook-plugin"));
        instance.transformPom(pom, tmpDir.updatedPom(), true, true, false, 
false, null, null);
        POMReader reader = new POMReader();
        POMInfo info2 = reader.readPom(tmpDir.read(tmpDir.updatedPom()));
        
        List<Dependency> pluginDependencies = 
info2.getDependencies().get(PLUGIN_MANAGEMENT_DEPENDENCIES);
        assertNotNull("null list", pluginDependencies);
        assertEquals("number of plugin dependencies", 1, 
pluginDependencies.size());
        assertEquals("dependency", 
"org.jboss.logging:jboss-logging-processor:jar:1.0.1.Final::null", 
pluginDependencies.get(0).toString());
    }

Reply via email to