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

        

Reply via email to