It's somewhat weird to reply to my own post.  I've figured that the
problem is in ant.bat.  The part where it tries to "slurp" the arguments
doesn't work with spaces.  I actually don't know why the code is there
since I used the %* (which means %1 - %9) to pass the argument to java
and it seems to work all right.  (Is it because the number of arguments
can be more than 9??)  Anyway, here is the patch for ant.bat that I used
to get this working:


(Note that I've only tested it out using Windows NT 4 SP 6a, somebody
should try this under Win 2K and 98)

17a18,29
> rem Slurp the command line arguments.  This loop allows for an unlimited number of
> rem agruments (up to the command line limit, anyway).
>
> set ANT_CMD_LINE_ARGS=
>
> :setupArgs
> if "%1"=="" goto doneArgs
> set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
> shift
> goto setupArgs
>
> :doneArgs
64c76
< %_JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%"
%ANT_OPTS% org.apache.tools.ant.Main %*
---
> %_JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%" %ANT_OPTS% 
>org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
68c80
< %JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%"
-Djikes.class.path=%JIKESPATH% %ANT_OPTS% org.apache.tools.ant.Main %*
---
> %JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%" 
>-Djikes.class.path=%JIKESPATH% %ANT_OPTS% org.apache.tools.ant.Main 
>%ANT_CMD_LINE_ARGS%
72a85
> set ANT_CMD_LINE_ARGS=                                                        

Can the Ant team take a look at the patch?

Will



William Lee wrote:
> 
> Doing ant "-DPROP=dir with space" would yield the same error... BTW, if
> anyone knows how to get the short name (with the ~) for the current
> directory and can assign it to a variable I'd be grateful.  It's
> somewhat unrelated to ant, but it's nice to have this working with ant
> script so we can all pass in path name as argument.  The dir /x would
> list the name fine but here is what I'm doing:
> 
> for /F "eol=; delims=," %%f in ('cd') do (
>         set TARGET_DIR=%%f
> )
> 
> ant -DTARGET_DIR=%TARGET_DIR%
> 
> etc...
> 
> 'cd' would yield the full path name.  What I did here is to assign the
> current directory to the TARGET_DIR variable and pass it to the ant
> script.  This works perfectly fine if the directory doesn't have space
> in it.  Does anyone know how I can convert the long name to short name?
> 
> Will
> 
> Nico Seessle wrote:
> >
> > ----- Original Message -----
> > From: "William Lee" <[EMAIL PROTECTED]>
> > To: "Ant User" <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 16, 2001 5:16 AM
> > Subject: Passing in -D argument with space to the ant.bat script
> >
> > > The "ant.bat" script that comes with Ant 1.2 doesn't seem to support -D
> > > options with space in it.  For example, I can do:
> > >
> > > c:\> ant -DPROP="dir with space"
> > >
> > > I'll get:
> > >
> > > with was unexpected at this time.
> > >
> > Can you try out
> >
> > c:\> ant "-DPROP=dir with space"?
> >
> > Looks funny, but may work better...
> >
> > Nico

Reply via email to