[jira] Commented: (MNG-3356) Multiple -Dkey=value command line options not handled correctly
[ http://jira.codehaus.org/browse/MNG-3356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=138511#action_138511 ] Paul Cager commented on MNG-3356: - I've investigated this further (see Apache's list: http://mail-archives.apache.org/mod_mbox/commons-user/200805.mbox/[EMAIL PROTECTED]). In summary I think version 1.1 is so broken that it is impossible to handle multiple -D type arguments. I think changing to use hasArgs() (plural) just makes cli 1.1 fall over in a different way. Here's an extract of the email I sent to Apache: As far as I can see it is simply not possible to use commons-cli to parse repeating options, such as occur in ant: ant -Dproperty1=value1 -Dproperty2=value2 compile Cli *does* have a junit test for ant-type options, but it unfortunately doesn't catch the error because it tests the command line: ant -Dproperty1=value1 -Dproperty2=value2 -projecthelp I attach a patch for the junit test (Cli-junit.patch) that will provoke the error, if you want to try it yourself. _Here's what I think is happening:_ The unit test (and the work-around suggested in issue 137) creates the D option using hasArgs() [note the 's' on the end of the method name]. Using hasArgs() for the D option causes cli to assume that all arguments following the -D (until it encounters another option) belong to the -D option. I've probably not explained that clearly so here's an example: ant -Dproperty1=value1 -Dproperty2=value2 compile will treat compile as though it was -Dcompile. getArgs() will return 0 elements, rather than one (compile). If instead you construct the D option using hasArg() [singular] then it will *not* interpret the second -D as an option. getArgs() will return 2 elements: property2=value2 and compile. getOptionValues() will return only the first -D value. This problem first came to light when Debian upgraded CLI from 1.0 to 1.1, and caused Debian's Maven package to fail (the standard Maven package uses cli 1.0 of course). As part of the Debian packaging I have created a quick-and-dirty patch which allows Maven to work (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=469082 for the Debian bug report, and I have attached the patch (MultiOptions.patch). I would guess that a proper fix would be rather more elegant than my patch. Multiple -Dkey=value command line options not handled correctly --- Key: MNG-3356 URL: http://jira.codehaus.org/browse/MNG-3356 Project: Maven 2 Issue Type: Bug Components: Command Line Affects Versions: 2.0.8 Reporter: Christian Koelle Priority: Critical Fix For: 2.0.x Attachments: command-line.patch After upgrading to 2.0.8 on Debian the handling of multiple (more than one) -Dkey=value cli options fail, i.e. something like: mvn plugin:goal -Dkey1=value1 -Dkey2=value2 fails with: Invalid task 'key2=value2': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal -- 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
[jira] Commented: (MNG-3356) Multiple -Dkey=value command line options not handled correctly
[ http://jira.codehaus.org/browse/MNG-3356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_124581 ] Christian Koelle commented on MNG-3356: --- OK, thanks. It works fine now with the updated Debian package. But is this not also a problem for the general Maven release? Is it necessary to apply this patch for Maven 2.0.9? Or are there no plans to upgrade to commons-cli 1.1? Multiple -Dkey=value command line options not handled correctly --- Key: MNG-3356 URL: http://jira.codehaus.org/browse/MNG-3356 Project: Maven 2 Issue Type: Bug Components: Command Line Affects Versions: 2.0.8 Reporter: Christian Koelle Priority: Critical Attachments: command-line.patch After upgrading to 2.0.8 on Debian the handling of multiple (more than one) -Dkey=value cli options fail, i.e. something like: mvn plugin:goal -Dkey1=value1 -Dkey2=value2 fails with: Invalid task 'key2=value2': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal -- 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
[jira] Commented: (MNG-3356) Multiple -Dkey=value command line options not handled correctly
[ http://jira.codehaus.org/browse/MNG-3356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_119619 ] Paul Cager commented on MNG-3356: - This error will only affect the *Debian* Maven package, and happens because Debian are using commons-cli version 1.1 (rather than version 1.0 which standard Maven uses). Please see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=458895 and http://issues.apache.org/jira/browse/CLI-137 for a full description of why this is happening. A revised Debian package is being prepared. In summary: version 1.1 of commons-cli introduced a more rigid interpretation of the API specification for the hasArg() method of OptionBuilder, such that hasArg() implies there can only be *one* instance of the argument (I think there is a remaining bug in the commons.cli package which I'll take up with them). This means that the second -D option is taken to be an argument, rather than an option. In version 1.0 of commons-cli this restriction was never enforced. Maven should really be calling the hasArgs() method to indicate there can be unlimited -D arguments. I've attached the patch Debian is using for this problem. Multiple -Dkey=value command line options not handled correctly --- Key: MNG-3356 URL: http://jira.codehaus.org/browse/MNG-3356 Project: Maven 2 Issue Type: Bug Components: Command Line Affects Versions: 2.0.8 Reporter: Christian Koelle Priority: Critical After upgrading to 2.0.8 on Debian the handling of multiple (more than one) -Dkey=value cli options fail, i.e. something like: mvn plugin:goal -Dkey1=value1 -Dkey2=value2 fails with: Invalid task 'key2=value2': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal -- 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