buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Assaf Arkin" <ar...@intalio.com>
Subject Re: Trouble running java task with 1.3.0
Date Thu, 08 May 2008 22:36:27 GMT
On Unix, the system method behaves differently depending on whether you call
it with one argument or array of arguments.
With one argument, it passes the string to the shell for expansion, the
shell then calls the command.  So names with spaces must be quoted or
escaped, and glob patterns are expanded to file names.  system('ls *') works
the same way as typing ls * on the command line, and system('ls "path with
spaces") is necessary.

With array of arguments, those are passed directly to the program without
expansion.  Adding quotes or escaping arguments actually passes the wrong
value to the program, so system('ls', "\"quoted\"") will pass "quoted" as
the filename, not quoted.  Likewise, glob patterns are not expanded, so
system('ls', '*') will fail since there's no file by the name '*'.

I believe it's the same behavior on Windows.

Tricky part.  If you call Command.java('*') then it should fail since
there's no file by the name '*'.  But the trace would show "java *".  If you
copy the output of trace and run that straight from the command line, shell
expansion kicks in, and the command runs with list of all files in the local
directory.

So the trace output should not be trusted.  That would be the place to add
quoting and see if the same command can be run from the command line:

puts cmd_args.map(&:inspect).join(' ') if Buildr.application.options.trace

Assaf

On Thu, May 8, 2008 at 2:11 PM, Victor Hugo Borja <vic.borja@gmail.com>
wrote:

> Harish, could you with the following change:
>
> http://github.com/vic/buildr/commit/b921093029bc4f9e6f9ee59e6d42f5357fbb7e18
> Patch your commands.rb, and let us know if this works on windows.
>
> We really need more specs for windows paths, so If anyone running windows
> would like to contribute a failing spec for this it would be great.
>
> On Thu, May 8, 2008 at 3:52 PM, Harish Krishnaswamy <
> harishkswamy@gmail.com>
> wrote:
>
> > Actually, its not a space problem... I patched the
> > Java::Commands.classpath_from method to put the path names within quotes
> > and
> > its still wouldn't run. When I copy the command from trace and run it
> > unchanged, it runs. I am not sure what the problem is, any help is much
> > appreciated.
> >
> > Here's my output which is not very helpful...
> >
> > Running java com.google.gwt.dev.GWTCompiler
> > rake aborted!
> > Failed to execute java com.google.gwt.dev.GWTCompiler, see errors above
> >
> > It appears like the errors are being swallowed.
> >
> > -Harish
> >
> > On Thu, May 8, 2008 at 3:54 PM, Harish Krishnaswamy <
> > harishkswamy@gmail.com>
> > wrote:
> >
> > > No, I am trying to run the GWT compiler from within build using the
> java
> > > commnd.
> > >
> > > def build_gwt_project(module_name)
> > >     build do
> > >       Java::Commands.java 'com.google.gwt.dev.GWTCompiler', '-out',
> > > 'target/gwt/out', '-gen', 'target/gwt/gen', module_name,
> > >         :java_args => ['-Xmx256M'],
> > >         :classpath => [FileList['src/main/java', 'src/main/resources',
> > > 'target/classes'], source_deps], :verbose => true
> > >     end
> > > end
> > >
> > > I use this function from within my project definition.
> > >
> > >
> > >
> > > On Thu, May 8, 2008 at 3:44 PM, Daniel Spiewak <djspiewak@gmail.com>
> > > wrote:
> > >
> > >> It does have a space: "Daniel Spiewak".  Is this the javac build or
> > >> dependency resolution?
> > >>
> > >> Daniel
> > >>
> > >> On Thu, May 8, 2008 at 2:42 PM, Harish Krishnaswamy <
> > >> harishkswamy@gmail.com>
> > >> wrote:
> > >>
> > >> > I didn't have a problem either until I upgraded to 1.3.0 today.
> Looks
> > >> like
> > >> > your home doesn't have a space or does it, I can't tell with a line
> > >> break
> > >> > in
> > >> > between your name.
> > >> >
> > >> > On Thu, May 8, 2008 at 3:36 PM, Daniel Spiewak <djspiewak@gmail.com
> >
> > >> > wrote:
> > >> >
> > >> > > It's weird that you're having troubles with this my repository
is
> > also
> > >> > > under
> > >> > > my user home, and Buildr's never given me trouble with it:
> > >> > C:\Users\Daniel
> > >> > > Spiewak\.m2\repository
> > >> > >
> > >> > > Daniel
> > >> > >
> > >> > > On Thu, May 8, 2008 at 2:30 PM, Harish Krishnaswamy <
> > >> > > harishkswamy@gmail.com>
> > >> > > wrote:
> > >> > >
> > >> > > > Hi,
> > >> > > >
> > >> > > > The java task is not escaping the classpath when there are
> spaces
> > in
> > >> > the
> > >> > > > path names (my repository is my user home on windows that
would
> be
> > >> > under
> > >> > > > "Documents and Settings" :(). I copied the command from
trace
> and
> > >> > > enclosed
> > >> > > > the path names with quotes and was able to run it successfully.
> Is
> > >> > there
> > >> > > a
> > >> > > > work around for this other than moving my local repository?
> > Thanks.
> > >> > > >
> > >> > > > -Harish
> > >> > > >
> > >> > >
> > >> >
> > >>
> > >
> > >
> >
>
>
>
> --
> vic
>
> Quaerendo invenietis.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message