You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by vb...@apache.org on 2008/03/07 00:46:51 UTC
svn commit: r634463 - in /incubator/buildr/trunk: lib/buildr/cobertura.rb
lib/buildr/jdepend.rb lib/core/common.rb lib/java/artifact.rb
lib/java/java.rb lib/java/nailgun.rb spec/common_spec.rb
Author: vborja
Date: Thu Mar 6 15:46:42 2008
New Revision: 634463
URL: http://svn.apache.org/viewvc?rev=634463&view=rev
Log:
Windows path fixes for jdepend and cobertura.
Fixes to Java::Commands.java to run on windows
Added File.normalize_path, it's just File.expand_path but for windows systems
it capitalizes the drive name and ensures the path has backslashes
Modified:
incubator/buildr/trunk/lib/buildr/cobertura.rb
incubator/buildr/trunk/lib/buildr/jdepend.rb
incubator/buildr/trunk/lib/core/common.rb
incubator/buildr/trunk/lib/java/artifact.rb
incubator/buildr/trunk/lib/java/java.rb
incubator/buildr/trunk/lib/java/nailgun.rb
incubator/buildr/trunk/spec/common_spec.rb
Modified: incubator/buildr/trunk/lib/buildr/cobertura.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/cobertura.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/cobertura.rb (original)
+++ incubator/buildr/trunk/lib/buildr/cobertura.rb Thu Mar 6 15:46:42 2008
@@ -46,11 +46,11 @@
end
def report_to(file = nil)
- File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
+ File.normalize_path(File.join(*["reports/cobertura", file.to_s].compact))
end
def data_file()
- File.expand_path("reports/cobertura.ser")
+ File.normalize_path("reports/cobertura.ser")
end
end
@@ -79,7 +79,7 @@
end
def report_to(file = nil)
- File.expand_path(File.join(*[report_dir, file.to_s].compact))
+ File.normalize_path(File.join(*[report_dir, file.to_s].compact))
end
# :call-seq:
Modified: incubator/buildr/trunk/lib/buildr/jdepend.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/jdepend.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/jdepend.rb (original)
+++ incubator/buildr/trunk/lib/buildr/jdepend.rb Thu Mar 6 15:46:42 2008
@@ -28,7 +28,8 @@
end
def paths()
- Project.projects.map(&:compile).each(&:invoke).map(&:target).map(&:to_s).select { |path| File.exist?(path) }
+ Project.projects.map(&:compile).each(&:invoke).map(&:target).
+ map(&:to_s).select { |path| File.exist?(path) }.map { |path| File.normalize_path(path) }
end
end
Modified: incubator/buildr/trunk/lib/core/common.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/common.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/common.rb (original)
+++ incubator/buildr/trunk/lib/core/common.rb Thu Mar 6 15:46:42 2008
@@ -19,7 +19,32 @@
require 'core/transports'
require 'open-uri'
require 'uri/open-sftp'
+require 'rbconfig'
+class File
+ class << self
+
+ # Just like File.expand_path, but for windows systems it
+ # capitalizes the drive name and ensures backslashes are used
+ def normalize_path(path, *dirs)
+ path = File.expand_path(path, *dirs)
+ if Config::CONFIG["host_os"] =~ /win/i
+ path.gsub!('/', '\\').gsub!(/^[a-zA-Z]+:/) { |s| s.upcase }
+ else
+ path
+ end
+ end
+
+ # Return the timestamp of file, without having to create a file task
+ def timestamp(file)
+ if File.exist?(file)
+ File.mtime(file)
+ else
+ Rake::EARLY
+ end
+ end
+ end
+end
class Hash
Modified: incubator/buildr/trunk/lib/java/artifact.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/artifact.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/artifact.rb (original)
+++ incubator/buildr/trunk/lib/java/artifact.rb Thu Mar 6 15:46:42 2008
@@ -397,7 +397,7 @@
#
# The default path is .m2/repository relative to the home directory.
def local()
- @local ||= ENV['M2_REPO'] || ENV["local_repo"] || File.join(ENV['HOME'], ".m2/repository")
+ @local ||= File.expand_path(ENV['M2_REPO'] || ENV["local_repo"] || File.join(ENV['HOME'], ".m2/repository"))
end
# :call-seq:
Modified: incubator/buildr/trunk/lib/java/java.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/java.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/java.rb (original)
+++ incubator/buildr/trunk/lib/java/java.rb Thu Mar 6 15:46:42 2008
@@ -15,7 +15,7 @@
require 'core/project'
-require 'rbconfig'
+
ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
if PLATFORM == 'java'
require File.join(File.dirname(__FILE__), 'jruby')
@@ -60,7 +60,7 @@
puts "Running #{name}" if verbose
block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
puts cmd_args.join(' ') if Rake.application.options.trace
- system(cmd_args.map { |arg| %Q{"#{arg}"} }.join(' ')).tap do |ok|
+ system(*cmd_args).tap do |ok|
block.call ok, $?
end
end
@@ -199,7 +199,7 @@
# Returns the path to the specified Java command (with no argument to java itself).
def path_to_bin(name = nil)
home = ENV['JAVA_HOME'] or fail 'Are we forgetting something? JAVA_HOME not set.'
- File.join(home, 'bin', name.to_s)
+ File.normalize_path(File.join(home, 'bin', name.to_s))
end
# :call-seq:
@@ -208,7 +208,8 @@
# Extracts the classpath from the options, expands it by calling artifacts, invokes
# each of the artifacts and returns an array of paths.
def classpath_from(options)
- Buildr.artifacts(options[:classpath] || []).map(&:to_s).each { |t| task(t).invoke }
+ Buildr.artifacts(options[:classpath] || []).map(&:to_s).
+ map { |t| task(t).invoke; File.normalize_path(t) }
end
end
Modified: incubator/buildr/trunk/lib/java/nailgun.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/nailgun.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/nailgun.rb (original)
+++ incubator/buildr/trunk/lib/java/nailgun.rb Thu Mar 6 15:46:42 2008
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations under
# the License.
-require 'rbconfig'
-
module Buildr
# See the nailgun_help method for documentation.
@@ -308,30 +306,13 @@
module Util
extend self
- def normalize_path(*args)
- path = File.expand_path(*args)
- if Config::CONFIG["host_os"] =~ /win/i
- path.gsub!('/', '\\').gsub!(/^[a-zA-Z]+:/) { |s| s.upcase }
- else
- path
- end
- end
-
- def timestamp(file)
- if File.exist?(file)
- File.mtime(file)
- else
- Rake::EARLY
- end
- end
-
def find_buildfile(pwd, candidates, nosearch=false)
candidates = [candidates].flatten
- buildfile = candidates.find { |c| File.file?(Util.normalize_path(c, pwd)) }
- return Util.normalize_path(buildfile, pwd) if buildfile
+ buildfile = candidates.find { |c| File.file?(File.normalize_path(c, pwd)) }
+ return File.normalize_path(buildfile, pwd) if buildfile
return nil if nosearch
updir = File.dirname(pwd)
- return nil if Util.normalize_path(updir) == Util.normalize_path(pwd)
+ return nil if File.normalize_path(updir) == File.normalize_path(pwd)
find_buildfile(updir, candidates)
end
@@ -457,7 +438,7 @@
attr_accessor :runtime
def initialize(path, *requires)
- @path = Util.normalize_path(path)
+ @path = File.normalize_path(path)
@requires = requires.dup
end
@@ -466,7 +447,7 @@
end
def last_modification
- Util.timestamp(path)
+ File.timestamp(path)
end
def should_be_loaded?
@@ -554,7 +535,7 @@
candidates = [opts.buildfile] if opts.buildfile
path = Util.find_buildfile(ctx.pwd, candidates, opts.nosearch) ||
- Util.normalize_path(candidates.first, ctx.pwd)
+ File.normalize_path(candidates.first, ctx.pwd)
if ctx.action == :delete
nail.out.println "Deleting runtime for #{path}"
@@ -695,7 +676,7 @@
JRuby.reference($nailgun_server))
load_service = runtime.getLoadService
load_service.getLoadPath.
- unshift Util.normalize_path('..', File.dirname(__FILE__))
+ unshift File.normalize_path('..', File.dirname(__FILE__))
load_service.require 'java/nailgun'
header.replace ["Created runtime[#{creator}]", runtime]
runtime
@@ -848,7 +829,7 @@
$nailgun_server.start_server
is_win = Config::CONFIG['host_os'] =~ /win/i
- bin_path = Util.normalize_path(installed_bin.to_s.pathmap("%d"))
+ bin_path = File.normalize_path(installed_bin.to_s.pathmap("%d"))
bin_name = installed_bin.to_s.pathmap("%f")
puts <<-NOTICE
Modified: incubator/buildr/trunk/spec/common_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/common_spec.rb?rev=634463&r1=634462&r2=634463&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/common_spec.rb (original)
+++ incubator/buildr/trunk/spec/common_spec.rb Thu Mar 6 15:46:42 2008
@@ -429,7 +429,7 @@
Dir['target/*'].sort.each do |file|
File.readable?(file).should be_true
File.writable?(file).should be_true
- (File.stat(file).mode & 0x0fff).should == 0664
+ (File.stat(file).mode & 0o200).should == 0o200
end
end
end