Uploaded image for project: 'Maven Archetype'
  1. Maven Archetype
  2. ARCHETYPE-235

DefaultPomManager.mergePoms ignores ordering of plugins

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-alpha-4
    • Fix Version/s: 2.0-alpha-5
    • Component/s: None
    • Labels:
      None

      Description

      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 ); }

      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              christian-bauer Christian Bauer
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: