diff options
author | Alex Coles <alex@alexcolesportfolio.com> | 2009-12-07 23:02:05 +0100 |
---|---|---|
committer | Alex Coles <alex@alexcolesportfolio.com> | 2009-12-07 23:02:05 +0100 |
commit | fbcc4e969b6a43bada20862c37770d1f83dc0e0a (patch) | |
tree | df622b97ad5c2dd7cd0285f94fe82dd34f85f23c /lib/rake/javaextensiontask.rb | |
parent | 069dd567f4b9e29d1894438f8fb8f9956a14dcc2 (diff) | |
download | rake-compiler-fbcc4e969b6a43bada20862c37770d1f83dc0e0a.tar.gz |
Fix handling of jar command line arguments
* Pass explicit list of .class files, not wildcard.
* Because jar output directory is same as directory containing .class files, it
appeared that the jar command line tool was trying to recursively jar itself.
* Handle case where $ in .class file names (seen with use of inner classes, etc.)
was being expanded out on *NIX systems.
* Change feature to test for the above.
* Thanks to Luis for helping work through this and ensuring compatibility with
both *NIX and Windows systems.
Signed-off-by: Alex Coles <alex@alexcolesportfolio.com>
Diffstat (limited to 'lib/rake/javaextensiontask.rb')
-rw-r--r-- | lib/rake/javaextensiontask.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/rake/javaextensiontask.rb b/lib/rake/javaextensiontask.rb index aee376a..caed109 100644 --- a/lib/rake/javaextensiontask.rb +++ b/lib/rake/javaextensiontask.rb @@ -77,7 +77,18 @@ execute the Rake compilation task using the JRuby interpreter. warn_once(not_jruby_compile_msg) unless defined?(JRUBY_VERSION) file "#{tmp_path}/#{binary(platf)}" => "#{tmp_path}/.build" do - sh "jar cf #{tmp_path}/#{binary(platf)} -C #{tmp_path} ." + + class_files = FileList["#{tmp_path}/**/*.class"]. + gsub("#{tmp_path}/", '') + + # avoid environment variable expansion using backslash + class_files.gsub!('$', '\$') unless windows? + + args = class_files.map { |path| + ["-C #{tmp_path}", path] + }.flatten + + sh "jar cf #{tmp_path}/#{binary(platf)} #{args.join(' ')}" end file "#{tmp_path}/.build" => [tmp_path] + source_files do |