You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Cyril Bouteille <Cy...@yahoo.com> on 2000/11/07 01:50:36 UTC

Passing property values with spaces to Ant

Hi,

I'm trying to pass a bunch of property values to Ant for dynamic
variables in my build and I'm running into problems when these values
contain spaces. For example, when passing a list of options as value of
a property, Ant tries to interpret these options.

Here's a simple testcase:
cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar="-op1 -op2"
Unknown arg: -op2

I tried a bunch of shell tricks such as:
cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar='-op1 -op2'
Unknown arg: -op2
cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar=-op1\ -op2 
Unknown arg: -op2
but nothing works...

Any idea on how to do this?
--
 Cyril Bouteille - Lead J2EE Software Engineer 
 Hotwire - San Francisco, California
 http://www.hotwire.com

Re: Passing property values with spaces to Ant

Posted by James Manning <jm...@computer.org>.
[Cyril Bouteille]
> I'm trying to pass a bunch of property values to Ant for dynamic
> variables in my build and I'm running into problems when these values
> contain spaces. For example, when passing a list of options as value of
> a property, Ant tries to interpret these options.
> 
> Here's a simple testcase:
> cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar="-op1 -op2"
> Unknown arg: -op2
> cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar='-op1 -op2'
> Unknown arg: -op2
> cyril@wyvern:~/p4/hotwire/2.0/build> ant -Dvar=-op1\ -op2 
> Unknown arg: -op2
> but nothing works...

In all of these cases, argv[1] will be -Dvar=-op1 -op2
so I'd probably give a double-wrapping trick a try:

ant '-Dvar="-op1 -op2"'

So argv[1] will now be -Dvar="-op1 -op2"

I have no idea if it will work
-- 
James Manning <jm...@computer.org>
GPG Key fingerprint = B913 2FBD 14A9 CE18 B2B7  9C8E A0BF B026 EEBB F6E4