[ 
https://issues.apache.org/jira/browse/MNG-2028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Herve Boutemy updated MNG-2028:
-------------------------------
    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

{noformat}
myproject
  tools
  libraries
    library1
    library2
    library3
{noformat}

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():

{code}
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);
                }
            }
 ...
{code}


  was:
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);
                }
            }
 ...


> Attached mojos with the @aggregator tag can yield bad results in a 
> multi-module project
> ---------------------------------------------------------------------------------------
>
>                 Key: MNG-2028
>                 URL: https://issues.apache.org/jira/browse/MNG-2028
>             Project: Maven
>          Issue Type: Bug
>          Components: Plugins and Lifecycle
>    Affects Versions: 2.0.2
>            Reporter: John Didion
>            Priority: Major
>
> 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
> {noformat}
> myproject
>   tools
>   libraries
>     library1
>     library2
>     library3
> {noformat}
> 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():
> {code}
> 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);
>                 }
>             }
>  ...
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to