You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Maxim Podkolzine (JIRA)" <ji...@codehaus.org> on 2010/02/08 14:42:55 UTC

[jira] Created: (MNG-4559) MAVEN_OPTS are incorrectly resolved in Unix

MAVEN_OPTS are incorrectly resolved in Unix
-------------------------------------------

                 Key: MNG-4559
                 URL: http://jira.codehaus.org/browse/MNG-4559
             Project: Maven 2 & 3
          Issue Type: Bug
    Affects Versions: 2.2.1
         Environment: OS: Linux, 2.6.32-11-generic, amd64.
Java: 1.6.0_17
            Reporter: Maxim Podkolzine


I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
MAVEN_OPTS="-Dfoo='bar baz'"

As a result the quotes are not resolved, causing Java failure:
Exception in thread "main" java.lang.NoClassDefFoundError: baz'
...

I couldn't figure out a way to make it work.

-- 
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-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Maxim Podkolzine (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=209537#action_209537 ] 

Maxim Podkolzine commented on MNG-4559:
---------------------------------------

Unfortunately no, java still thinks that -Dfoo=bar and baz are two different arguments.
After some time I found a quick hack in 'mvn' script:

exec "$JAVACMD" \
     "$MAVEN_OPTS" \
     ...

(instead of just $MAVEN_OPTS)

The argument is now resolved correctly. But this approach fails in some other cases, so it's not a complete solution.
Though it can be a clue.

> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: http://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

-- 
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] Issue Comment Edited: (MNG-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Maxim Podkolzine (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=210590#action_210590 ] 

Maxim Podkolzine edited comment on MNG-4559 at 2/18/10 3:30 AM:
----------------------------------------------------------------

Hi Anders,

I picked -D option just for example. In fact I needed to specify JavaAgent option, which has a format -javaagent:jar=values, and it is possible to have spaces in a jar path (though it's quiet rare) or in 'values'. Values are like normal java arguments, so the agent can easily require two mandatory arguments, which must be delimited by spaces. The problem is I can't tell Maven to treat -javaagent:jar=values as a single argument.
Note that if I start Maven without script and specify all arguments manually, everything is resolved right.

I understand that this issue might be addressed to Linux/bash developers, and it's not urgent for me now. But if you guys could find a workaround in mvn script to make it work, that would be great.

      was (Author: maximp):
    Hi Anders,

A picked -D option just for example. In fact I needed to specify JavaAgent option, which has a format -javaagent:jar=values, and it is possible to have spaces in a jar path (though it's quiet rare) or in 'values'. Values are like normal java arguments, so the agent can easily require two mandatory arguments, which must be delimited by spaces. The problem is I can't tell Maven to treat -javaagent:jar=values as a single argument.
Note that if I start Maven without script and specify all arguments manually, everything is resolved right.

I understand that this issue might be addressed to Linux/bash developers, and it's not urgent for me now. But if you guys could find a workaround in mvn script to make it work, that would be great.
  
> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: http://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

-- 
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-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Anders Kr. Andersen (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=210580#action_210580 ] 

Anders Kr. Andersen commented on MNG-4559:
------------------------------------------

Okay I get the clue
You are using white spaces in the -D value 

Maybe it is not intented to use whitespaces in values?

I think you should describe your usecase to show the relevance in whitespaces in values.

> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: http://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

-- 
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-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Maxim Podkolzine (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=210590#action_210590 ] 

Maxim Podkolzine commented on MNG-4559:
---------------------------------------

Hi Anders,

A picked -D option just for example. In fact I needed to specify JavaAgent option, which has a format -javaagent:jar=values, and it is possible to have spaces in a jar path (though it's quiet rare) or in 'values'. Values are like normal java arguments, so the agent can easily require two mandatory arguments, which must be delimited by spaces. The problem is I can't tell Maven to treat -javaagent:jar=values as a single argument.
Note that if I start Maven without script and specify all arguments manually, everything is resolved right.

I understand that this issue might be addressed to Linux/bash developers, and it's not urgent for me now. But if you guys could find a workaround in mvn script to make it work, that would be great.

> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: http://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

-- 
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-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Anders Kr. Andersen (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=209535#action_209535 ] 

Anders Kr. Andersen commented on MNG-4559:
------------------------------------------

Could it be that you should use back slash as escape for the space?

MAVEN_OPTS="-Dfoo=bar\ baz"

I have not tested this...

> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: http://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

-- 
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] (MNG-4559) MAVEN_OPTS are incorrectly resolved in Unix

Posted by "Dale Wijnand (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-4559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=302917#comment-302917 ] 

Dale Wijnand commented on MNG-4559:
-----------------------------------

This definitely needs to be tested, but I saw something about how this should be handled in an old Tomcat mailing list email, and I just had a problem with this when trying to add a -javaagent.

Here's my 3-second solution, which might or might not work for you, test it:
add "eval" in front of exec in the script, so it becomes:
eval exec "$JAVACMD" \
  $MAVEN_OPTS \
  -classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \
  "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
  "-Dmaven.home=${M2_HOME}"  \
  ${CLASSWORLDS_LAUNCHER} "$@"

Details:
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/local/Cellar/maven/current/libexec
Java version: 1.6.0_33, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_GB, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.4", arch: "x86_64", family: "mac"
                
> MAVEN_OPTS are incorrectly resolved in Unix
> -------------------------------------------
>
>                 Key: MNG-4559
>                 URL: https://jira.codehaus.org/browse/MNG-4559
>             Project: Maven 2 & 3
>          Issue Type: Bug
>    Affects Versions: 2.2.1
>         Environment: OS: Linux, 2.6.32-11-generic, amd64.
> Java: 1.6.0_17
>            Reporter: Maxim Podkolzine
>             Fix For: Issues to be reviewed for 3.x
>
>
> I'm trying to pass a quoted parameter through MAVEN_OPTS, e.g.
> MAVEN_OPTS="-Dfoo='bar baz'"
> As a result the quotes are not resolved, causing Java failure:
> Exception in thread "main" java.lang.NoClassDefFoundError: baz'
> ...
> I couldn't figure out a way to make it work.

--
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