Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1382

MavenPluginFacet does not get plugin dependencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 2.0.0.CR1
    • 1.4.3.Final
    • Plugin API
    • None
    • Hide

      Running this with junit should reproduce the problem:

      import static org.junit.Assert.*;
      
      import org.jboss.forge.maven.MavenPluginFacet;
      import org.jboss.forge.maven.plugins.MavenPluginBuilder;
      import org.jboss.forge.project.Project;
      import org.jboss.forge.project.dependencies.Dependency;
      import org.jboss.forge.project.dependencies.DependencyBuilder;
      import org.jboss.forge.test.AbstractShellTest;
      import org.junit.Test;
      
      public class Reproducer extends AbstractShellTest {
        @Test
        public void testPluginDependencyRetrieval() throws Exception {
          // Setup
          Project project = initializeJavaProject();
          MavenPluginFacet pluginFacet = project.getFacet(MavenPluginFacet.class);
          Dependency pluginArtifact = DependencyBuilder.create("maven-compiler-plugin");
          Dependency dependency = DependencyBuilder.create("org.jboss.errai:errai-common:2.4.3.Final");
          // Add plugin
          pluginFacet.addPlugin(MavenPluginBuilder.create().setDependency(DependencyBuilder.create(pluginArtifact)).addPluginDependency(dependency));
      
          // This will fail
          assertFalse(pluginFacet.getPlugin(pluginArtifact).getDirectDependencies().isEmpty());
        }
      }
      
      Show
      Running this with junit should reproduce the problem: import static org.junit.Assert.*; import org.jboss.forge.maven.MavenPluginFacet; import org.jboss.forge.maven.plugins.MavenPluginBuilder; import org.jboss.forge.project.Project; import org.jboss.forge.project.dependencies.Dependency; import org.jboss.forge.project.dependencies.DependencyBuilder; import org.jboss.forge.test.AbstractShellTest; import org.junit.Test; public class Reproducer extends AbstractShellTest { @Test public void testPluginDependencyRetrieval() throws Exception { // Setup Project project = initializeJavaProject(); MavenPluginFacet pluginFacet = project.getFacet(MavenPluginFacet.class); Dependency pluginArtifact = DependencyBuilder.create( "maven-compiler-plugin" ); Dependency dependency = DependencyBuilder.create( "org.jboss.errai:errai-common:2.4.3.Final" ); // Add plugin pluginFacet.addPlugin(MavenPluginBuilder.create().setDependency(DependencyBuilder.create(pluginArtifact)).addPluginDependency(dependency)); // This will fail assertFalse(pluginFacet.getPlugin(pluginArtifact).getDirectDependencies().isEmpty()); } }

      The constructor MavenPluginAdapter(org.apache.maven.model.Plugin) does not copy dependencies from its argument. Consequently, calling MavenPluginFacet.getPlugin(org.jboss.forge.project.dependencies.Dependency) retrieves a plugin with no dependencies regardless of the actual pom configuration.

              rhn-support-ggastald George Gastaldi
              mbarkley_jira Max Barkley (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: