Uploaded image for project: 'Maven Invoker Plugin'
  1. Maven Invoker Plugin
  2. MINVOKER-133

Using mergeUserSettings configuration parameter with multiple executions causes IllegalStateException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6
    • 1.8
    • None
    • Maven 3.0.4, Oracle Java jdk1.6.0_30

    Description

      When setting the mergeUserSettings configuration parameter [1] to "true" and configuring multiple executions for the maven-invoker-plugin, a java.lang.IllegalStateException with a message of "Cannot reset sourceLevel attribute; it is already set to: user-level" is thrown from org.apache.maven.settings.TrackableBase.setSourceLevel() [2] when merging the "private Settings settings" local variable [3] in org.apache.maven.plugin.invoker.AbstractInvokerMojo with the settings file configured through the "settingsFile" plugin configuration parameter [4] inside the AbstractInvokerMojo.runBuilds() [5] method.

      The problem appears to be that the MavenSettingsMerger [6] mutates the "recessive" org.apache.maven.settings.Settings parameter it receives in its "merge" method, setting the source level attribute of the Settings parameter. TrackableBase (which Settings extends) has a rule that its source level attribute can only be set one time. When multiple executions are configured for the maven-invoker-plugin, it appears all executions share the same org.apache.maven.settings.Settings instance. Therefore, when the second execution executes and org.apache.maven.settings.SettingsUtils.merge() [7] is called, which calls org.apache.maven.settings.merge.MavenSettingsMerger.merge() [6], and the source level attribute is set on the same Settings instance a second time, the IllegalStateException is thrown.

      The same IllegalStateException occurs in a maven reactor project containing multiple modules, each which configure one execution for the maven-invoker-plugin.

      I don't know enough about the history behind why the MavenSettingsMerger.merge() method mutates the "recessive" Settings parameter to be able to determine if this logic is correct. In lieu of making changes in MavenSettingsMerger, a copy of the Settings instance variable, without setting the source level attribute, could be made in AbstractInvokerMojo.runBuilds() [5] before passing this variable to SettingsUtils.merge().

      [1] http://maven.apache.org/plugins/maven-invoker-plugin-1.6/run-mojo.html#mergeUserSettings

      [2] http://maven.apache.org/ref/3.0.4/maven-settings/xref/org/apache/maven/settings/TrackableBase.html#56

      [3] http://maven.apache.org/plugins/maven-invoker-plugin-1.6/xref/org/apache/maven/plugin/invoker/AbstractInvokerMojo.html#438

      [4] http://maven.apache.org/plugins/maven-invoker-plugin-1.6/run-mojo.html#settingsFile

      [5] http://maven.apache.org/plugins/maven-invoker-plugin-1.6/xref/org/apache/maven/plugin/invoker/AbstractInvokerMojo.html#1039

      [6] http://maven.apache.org/ref/3.0.4/maven-settings-builder/xref/org/apache/maven/settings/merge/MavenSettingsMerger.html#38

      [7] http://maven.apache.org/ref/3.0.4/maven-core/xref/org/apache/maven/settings/SettingsUtils.html#40

      [8] http://maven.apache.org/guides/mini/guide-multiple-modules.html

      Attachments

        1. maven-invoker-bug-reactor - build output.txt
          43 kB
          Curt Fulcher
        2. maven-invoker-bug-reactor.zip
          9 kB
          Curt Fulcher
        3. maven-invoker-bug - build output.txt
          40 kB
          Curt Fulcher
        4. maven-invoker-bug.zip
          4 kB
          Curt Fulcher

        Activity

          People

            rfscholte Robert Scholte
            curt.fulcher Curt Fulcher
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: