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

Attached mojos with the @aggregator tag can yield bad results in a multi-module project

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 2.0.2
    • None
    • Plugins and Lifecycle
    • None

    Description

      I am using an attached version of the directory assembly plugin. I also have a multi-module project that is several levels deep. Here's an overview

      myproject
        tools
        libraries
          library1
          library2
          library3
      

      If I configure the attached directory assembly plugin in library1's POM and then run maven install from the myproject directory, I get errors about dependency resolution because the presence of the @aggregator tag causes maven to try and resolve dependencies for all modules in the entire project. That means it's trying to resolve dependencies for library3, which is a problem if library3 depends on library2, which hasn't been built yet.

      It makes sense to me that dependency resolution should only happen on the sub-modules of the POM that configures the aggregator plugin, not all modules in the project.

      If this makes sense then I think the fix would be in DefaultPluginManager.executeMojo():

      if ( mojoDescriptor.isDependencyResolutionRequired() != null )
              {
                  Collection projects;
      
                  if ( mojoDescriptor.isAggregator() && project.getModules() != null && !project.getModules().isEmpty())
                  {
                      List modules = project.getModules();
                      projects = new ArrayList(modules.size());
                      for (Iterator itr = modules.iterator(); itr.hasNext();) {
                          String module = (String) itr.next();
                          MavenProject moduleProject = // load the project for the module...don't know exactly how to do this
                          projects.add(moduleProject);
                      }
                  }
       ...
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jdidion John Didion
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: