Maven 2 & 3
  1. Maven 2 & 3
  2. MNG-1088

Plugins built and used within the same multiproject build fail unless lifecycle phase is compile or later

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0 (RC)
    • Component/s: Plugins and Lifecycle
    • Labels:
      None
    • Environment:
      Win2000 Pro
      Problem occurs on M2-2.0-BETA-2 as well as current SVN HEAD (M2-2.0-beta-4-SNAPSHOT)
    • Complexity:
      Intermediate
    • Number of attachments :
      0

      Description

      In my scenario, I have a plugin and the code that /uses/ this plugin within the same multiproject build. Example layout:

      - root-project
      +- plugins-root
      |+- plugin-project (2)
      +- application-root
       +- application-module (1)
      

      In my situation, application-module (1) references plugin-project (2) as a plugin.

      If I do m2 eclipse:eclipse in on the root project, I get the following NPE:

      java.lang.NullPointerException
              at org.codehaus.plexus.DefaultPlexusContainer.addJarResource(DefaultPlexusContainer.java:1351)
              at org.codehaus.plexus.DefaultPlexusContainer.createChildContainer(DefaultPlexusContainer.java:244)
              at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginManager.java:286)
              at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:186)
              at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:161)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1057)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle(DefaultLifecycleExecutor.java:1022)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:854)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:737)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:721)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:517)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:498)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:307)
              at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
              at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:217)
              at org.apache.maven.cli.MavenCli.main(MavenCli.java:247)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
              at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
              at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
              at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
      

      After a bit of digging around, I have tracked this down to the fact that the plugin project's artifact is a ActiveProjectArtifact in this context, and before a compile has been achieved, ActiveProjectArtifact.getFile() returns null (because it returns the project artifact's file, which is null).

      This same issue is triggered if any lifecycle phase prior to 'compile' is requested on the root project.

      There is a workaround, which is to execute the troublesome goal from within the 'application-root' project, but I can't help but think this is something that should just work. Unfortunately, I can't see a clean solution to this right now. The only thing I can think is that having an intra-reactor plugin dependency should force the compile lifecycle to execute on that plugin prior to the plugin being added to the plugin manager. Unfortunately I'm struggling to understand how to achieve that at the moment.

      If a solution to this can't be found, it is probably worth adding an error trap within the plugin manager to catch errant ActiveProjectArtifacts before they are added to plexus and display a more helpful error message.

      I'll have a think and see if I can find an elegant solution.

        Issue Links

          Activity

          Hide
          Paul Russell added a comment -

          Gah, sorry, stupidly thought you could use HTML in the issue descriptions.

          Show
          Paul Russell added a comment - Gah, sorry, stupidly thought you could use HTML in the issue descriptions.

            People

            • Assignee:
              Brett Porter
              Reporter:
              Paul Russell
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: