[ 
https://jira.codehaus.org/browse/MINVOKER-133?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Scholte closed MINVOKER-133.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.8
         Assignee: Robert Scholte

Fixed in [r1410797|http://svn.apache.org/viewvc?rev=1410797&view=rev]
Thanks for the analysis and integration-tests, it saved me a lot of time!

                
> Using mergeUserSettings configuration parameter with multiple executions 
> causes IllegalStateException
> -----------------------------------------------------------------------------------------------------
>
>                 Key: MINVOKER-133
>                 URL: https://jira.codehaus.org/browse/MINVOKER-133
>             Project: Maven 2.x Invoker Plugin
>          Issue Type: Bug
>    Affects Versions: 1.6
>         Environment: Maven 3.0.4, Oracle Java jdk1.6.0_30
>            Reporter: Curt Fulcher
>            Assignee: Robert Scholte
>             Fix For: 1.8
>
>         Attachments: maven-invoker-bug - build output.txt, 
> maven-invoker-bug-reactor - build output.txt, maven-invoker-bug-reactor.zip, 
> maven-invoker-bug.zip
>
>
> 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

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to