You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Kai Reichert (JIRA)" <ji...@codehaus.org> on 2009/03/20 16:59:12 UTC

[jira] Commented: (ARCHETYPE-235) DefaultPomManager.mergePoms ignores ordering of plugins

    [ http://jira.codehaus.org/browse/ARCHETYPE-235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=170426#action_170426 ] 

Kai Reichert commented on ARCHETYPE-235:
----------------------------------------

At our company we had the same problem with merging of multiple partial archetypes.

So we decided to try out the above mentioned solution. It works perfectly, but only sorts the plugins. 
There are more elements to merge inside a pom.xml than just plugins. We also need profiles, properties, etc.

To cut a long story short we created a patch which implements many of the missing use cases while merging pom.xml's. It can be applied to the 2.0-alpha-4 version of the archetype module.

It would be great if more people test the patch and that someone will intergrate it into maven.

> DefaultPomManager.mergePoms  ignores ordering of plugins
> --------------------------------------------------------
>
>                 Key: ARCHETYPE-235
>                 URL: http://jira.codehaus.org/browse/ARCHETYPE-235
>             Project: Maven Archetype
>          Issue Type: Bug
>    Affects Versions: 2.0-alpha-4
>            Reporter: Christian Bauer
>
> when you invoke an archetype with attribute partial=true (<archetype-descriptor partial="true" .... ) the pom of the archetype-resources is merged with the existing pom.
> During the merge of build plugins the DefaultPomManager ignores the ordering of the plugins in the archetype (generatedModel).
> The DefaultPomManager uses the ordering of the map generatedPluginsByIds :
>             Map pluginsByIds = model.getBuild().getPluginsAsMap();
>             Map generatedPluginsByIds = generatedModel.getBuild().getPluginsAsMap();
>             Iterator generatedPluginsIds = generatedPluginsByIds.keySet().iterator();
>             while ( generatedPluginsIds.hasNext() )
>             {
>                 String generatedPluginsId = (String) generatedPluginsIds.next();
>                 if ( !pluginsByIds.containsKey( generatedPluginsId ) )
>                 {
>                     model.getBuild().addPlugin((Plugin) generatedPluginsByIds.get( generatedPluginsId )
>                     );
>                 }
>                 else
>                 {
>                     getLogger().warn( "Can not override plugin: " + generatedPluginsId );
>                 }
>             }
> When the build process depends on the ordering of the plugins it may fail.
> The solution is to iterate over the list of plugins instead of the map
>             Map pluginsByIds = model.getBuild().getPluginsAsMap();
>             List generatedPlugins = generatedModel.getBuild().getPlugins();
>             Iterator generatedPluginsIterator = generatedPlugins.iterator();
>             while ( generatedPluginsIterator.hasNext() )
>             {
>             	Plugin plugin = (Plugin)generatedPluginsIterator.next();
>                 String generatedPluginsId = plugin.getKey();
>                 if ( !pluginsByIds.containsKey( generatedPluginsId ) )
>                 {
>                     model.getBuild().addPlugin(plugin);
>                 }
>                 else
>                 {
>                     getLogger().warn( "Can not override plugin: " + generatedPluginsId );
>                 }
>             }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira