jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2 & 3
  • MNG-2190

-Dkey=value parameters cannot include spaces in the value

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 2.0.2
  • Fix Version/s: None
  • Component/s: Command Line
  • Labels:
    None
  • Environment:
    Darwin
  • Complexity:
    Intermediate

Description

Even if I properly escape spaces in a path at the shell level, Maven seems to re-split the command parameters. For instance, on Unix, the following should all run the compile goal with a property foo="bar baz":

$ mvn compile "-Dfoo=bar baz"
$ mvn compile -Dfoo="bar baz"
$ mvn compile -Dfoo=bar\ baz

But in fact, Maven fails, complaining that "baz" is an invalid task:

[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ----------------------------------------------------------------------------
[INFO] Invalid task 'baz': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ----------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Mar 29 15:21:01 EST 2006
[INFO] Final Memory: 1M/2M
[INFO] ----------------------------------------------------------------------------

Is this intended behavior? Seems as if Maven is unnecessarily splitting the string, when the OS already does as much.

I was merely trying to run:

mvn deploy:deploy-file "-Dfile=/Users/me/Desktop/Bellicose SDK/lib/Bellicose.jar" ...

In my case, it's practical to work around by renaming the Bellicose SDK folder, but it seems as if Windows users stuck with "C:\Documents and Settings\..." might have a harder time of it.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    MNG-2190.patch
    31/Mar/06 8:28 PM
    7 kB
    Gordon Henriksen

Issue Links

duplicates

Bug - A problem which impairs or prevents the functions of the product. MNG-1415 quoted arguments are not being protected

  • Critical - Crashes, loss of data, severe memory leak.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
is duplicated by

Bug - A problem which impairs or prevents the functions of the product. MRELEASE-436 Spaces in scmCommitPrefix cause errors in attempting to release

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
relates to

Bug - A problem which impairs or prevents the functions of the product. MNG-3529 mvn -Da=" " throws an excepltion

  • Trivial - Cosmetic problem like misspelt words or misaligned text.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Gordon Henriksen added a comment - 31/Mar/06 8:12 PM

Reopening with patch to use "$@" rather than trying to second-guess argv.

The current status quo fails on args like '-Dfoo=my "great" new project'. This is not a valid path on Windows, so I don't think I can adapt the integration test to suit. Probably could test on a property used for some other purpose, though.

It's probably true that not all shells support "$@", but I would be very surprised if anything installed at /bin/sh doesn't. Notably, ant's wrapper script uses "$@", so if that's "portable enough," then this patch should also be.

All integration tests do pass.

Show
Gordon Henriksen added a comment - 31/Mar/06 8:12 PM Reopening with patch to use "$@" rather than trying to second-guess argv. The current status quo fails on args like '-Dfoo=my "great" new project'. This is not a valid path on Windows, so I don't think I can adapt the integration test to suit. Probably could test on a property used for some other purpose, though. It's probably true that not all shells support "$@", but I would be very surprised if anything installed at /bin/sh doesn't. Notably, ant's wrapper script uses "$@", so if that's "portable enough," then this patch should also be. All integration tests do pass.
Hide
Permalink
Gordon Henriksen added a comment - 31/Mar/06 8:28 PM

Base revision for this patch is r390562. Integration tests pass.

Also, I'm not sure about this line in the deprecated maven-core/src/bin/m2 script:

. `dirname "$0"`/mvn

First of all, it breaks if dirname has whitespace, and secondly, I think it's redundant to the exec, seeing as how mvn ends with an exec. It was added with the $QUOTED_ARGS commit (presumably to initialize $QUOTED_ARGS in m2), but I didn't delete it here.

Show
Gordon Henriksen added a comment - 31/Mar/06 8:28 PM Base revision for this patch is r390562. Integration tests pass. Also, I'm not sure about this line in the deprecated maven-core/src/bin/m2 script: . `dirname "$0"`/mvn First of all, it breaks if dirname has whitespace, and secondly, I think it's redundant to the exec, seeing as how mvn ends with an exec. It was added with the $QUOTED_ARGS commit (presumably to initialize $QUOTED_ARGS in m2), but I didn't delete it here.
Hide
Permalink
Heinrich Nirschl added a comment - 23/Sep/07 1:59 AM

The approach taken in maven 2.0.7 still does not work as this example shows (with bash on Linux):

$ mvn help:effective-settings -Dfoo="ba\" bu"
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'help'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Invalid task 'bu': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Sun Sep 23 08:47:21 CEST 2007
[INFO] Final Memory: 1M/66M
[INFO] ------------------------------------------------------------------------

I think it's the responsibility of the shell wrapper to correctly pass the parameters to the java process. Workarounds in Java are just a mess.

Show
Heinrich Nirschl added a comment - 23/Sep/07 1:59 AM The approach taken in maven 2.0.7 still does not work as this example shows (with bash on Linux): $ mvn help:effective-settings -Dfoo="ba\" bu" [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'help'. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Invalid task 'bu': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: < 1 second [INFO] Finished at: Sun Sep 23 08:47:21 CEST 2007 [INFO] Final Memory: 1M/66M [INFO] ------------------------------------------------------------------------ I think it's the responsibility of the shell wrapper to correctly pass the parameters to the java process. Workarounds in Java are just a mess.
Hide
Permalink
Jason van Zyl added a comment - 30/Dec/09 2:05 PM

The commands all work in Maven 3.x.

Show
Jason van Zyl added a comment - 30/Dec/09 2:05 PM The commands all work in Maven 3.x.

People

  • Assignee:
    Unassigned
    Reporter:
    Gordon Henriksen
Vote (3)
Watch (3)

Dates

  • Created:
    30/Mar/06 6:51 AM
    Updated:
    20/May/10 12:18 PM
    Resolved:
    30/Dec/09 2:05 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.