Author: vborja
Date: Thu Jul 30 03:38:58 2009
New Revision: 799160
URL: http://svn.apache.org/viewvc?rev=799160&view=rev
Log:
BUILDR-292 Workaround for JRUBY-3381.
Recent JRuby versions 1.3+ have a bug in FileUtils.mv that doesn't allow to
rename a file when target directory is in different device, this workaround
is enabled when running on JRuby.
I was getting the "Permission denied" error when running on linux,
should this fix be enabled only or certain OS ?
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/lib/buildr/core/util.rb
Modified: buildr/trunk/CHANGELOG
URL:
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=799160&r1=799159&r2=799160&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Thu Jul 30 03:38:58 2009
@@ -9,6 +9,7 @@
* Added: BUILDR-295 Eclipse task: make 'M2_REPO' repository variable
configurable
* Change: Monkey-Patched FileUtils::sh on JRuby to use POSIX `system`
* Change: Updated to Rake 0.8.7, RSpec 1.2.6 and JRuby-openssl 0.5.1.
+* Fixed: BUILDR-292 Workaround for JRUBY-3381 on FileUtils.mv
* Fixed: BUILDR-23 Support for setting file mode when packaging (Ittay Dror).
* Fixed: BUILDR-290 Dependencies cannot be downloaded over SSL.
* Fixed: BUILDR-291 Local tasks do not support arguments (Ittay Dror).
Modified: buildr/trunk/lib/buildr/core/util.rb
URL:
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/util.rb?rev=799160&r1=799159&r2=799160&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/util.rb (original)
+++ buildr/trunk/lib/buildr/core/util.rb Thu Jul 30 03:38:58 2009
@@ -311,8 +311,29 @@
if Buildr::Util.java_platform?
require 'ffi'
+
+ # Fix for BUILDR-292.
+ # JRuby fails to rename a file on different devices
+ # this monkey-patch wont be needed when JRUBY-3381 gets resolved.
+ module FileUtils #:nodoc:
+ alias_method :__mv_native, :mv
+
+ def mv(from, to, options = nil)
+ dir_to = File.directory?(to) ? to : File.dirname(to)
+ Array(from).each do |from|
+ dir_from = File.dirname(from)
+ if File.stat(dir_from).dev != File.stat(dir_to).dev
+ cp from, to, options
+ rm to, options
+ else
+ __mv_native from, to, options
+ end
+ end
+ end
+ private :mv
+ end
- module RakeFileUtils
+ module RakeFileUtils #:nodoc:
def rake_merge_option(args, defaults)
defaults[:verbose] = false if defaults[:verbose] == :default