buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbo...@apache.org
Subject svn commit: r645206 - in /incubator/buildr/trunk: ./ addon/buildr/ lib/buildr/core/ lib/buildr/java/ rakelib/
Date Sun, 06 Apr 2008 07:53:48 GMT
Author: vborja
Date: Sun Apr  6 00:53:45 2008
New Revision: 645206

URL: http://svn.apache.org/viewvc?rev=645206&view=rev
Log:
Moved common utilities (used by Rakefile and Buildr itself) to buildr/core/util.
Unified execution of ruby, only use sudo if not on win_os and not owning the ruby installation.
Update addons to install gems using Buildr::SystemUtil.ruby

Added:
    incubator/buildr/trunk/lib/buildr/core/util.rb
Modified:
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/addon/buildr/cobertura.rb
    incubator/buildr/trunk/addon/buildr/jdepend.rb
    incubator/buildr/trunk/addon/buildr/nailgun.rb
    incubator/buildr/trunk/lib/buildr/core/addon.rb
    incubator/buildr/trunk/lib/buildr/core/application.rb
    incubator/buildr/trunk/lib/buildr/core/common.rb
    incubator/buildr/trunk/lib/buildr/java/commands.rb
    incubator/buildr/trunk/rakelib/doc.rake

Modified: incubator/buildr/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Sun Apr  6 00:53:45 2008
@@ -13,6 +13,9 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+# Load file/system utilities used shared between Buildr's runtime and this Rakefile
+require File.expand_path('lib/buildr/core/util', File.dirname(__FILE__))
+extend Buildr::SystemUtil
 
 # We need two specifications, for Ruby and Java, and one for the platform we run on.
 $specs = ['ruby', 'java'].inject({}) { |hash, platform|
@@ -54,37 +57,10 @@
   end
   hash.update(platform=>spec)
 }
-$spec = $specs[RUBY_PLATFORM =~ /java/ ? 'java' : 'ruby']
+$spec = $specs[java_platform? ? 'java' : 'ruby']
 
 $license_excluded = ['lib/core/progressbar.rb', 'spec/spec.opts', 'doc/css/syntax.css', '.textile',
'.haml']
 
-
-# Finds and returns path to executable.  Consults PATH environment variable.
-# Returns nil if executable not found.
-def which(name)
-  if Gem.win_platform?
-    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/') }.map
{ |path| "#{path}/#{name}.{exe,bat,com}" }
-  else
-    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
-  end
-  FileList[path].existing.first
-end
-
-# Runs Ruby with these command line arguments.  The last argument may be a hash,
-# supporting the following keys:
-#   :script   -- Runs the specified script (e.g., :script=>'gem')
-#   :sudo     -- Run as sudo on operating systems that require it.
-#   :verbose  -- Override Rake's verbose flag.
-def ruby(*args)
-  options = Hash === args.last ? args.pop : {}
-  cmd = []
-  cmd << 'sudo' if options.delete(:sudo) && !Gem.win_platform?
-  cmd << Config::CONFIG['ruby_install_name']
-  cmd << '-S' << options.delete(:command) if options[:command]
-  sh *cmd.push(*args.flatten).push(options)
-end
-
-
 begin
   require 'highline/import'
 rescue LoadError 
@@ -94,15 +70,10 @@
 # Setup environment for running this Rakefile (RSpec, Docter, etc).
 desc "If you're building from sources, run this task one to setup the necessary dependencies."
 task 'setup' do
-  installed = Gem::SourceIndex.from_installed_gems
   dependencies = $spec.dependencies
   dependencies << Gem::Dependency.new('win32console', nil) if Gem.win_platform? # Colors
for RSpec.
-  dependencies.select { |dep| installed.search(dep.name, dep.version_requirements).empty?
}.each do |dep|
-    puts "Installing #{dep} ..."
-    ruby 'install', dep.name, '-v', dep.version_requirements.to_s, :command=>'gem', :sudo=>true
-  end
+  install_gems(*dependencies)
 end
-
 
 namespace 'release' do
 

Modified: incubator/buildr/trunk/addon/buildr/cobertura.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/cobertura.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/cobertura.rb (original)
+++ incubator/buildr/trunk/addon/buildr/cobertura.rb Sun Apr  6 00:53:45 2008
@@ -49,11 +49,11 @@
       end
 
       def report_to(file = nil)
-        File.normalize_path(File.join(*["reports/cobertura", file.to_s].compact))
+        File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
       end
 
       def data_file()
-        File.normalize_path("reports/cobertura.ser")
+        File.expand_path("reports/cobertura.ser")
       end
 
     end
@@ -82,7 +82,7 @@
       end
 
       def report_to(file = nil)
-        File.normalize_path(File.join(*[report_dir, file.to_s].compact))
+        File.expand_path(File.join(*[report_dir, file.to_s].compact))
       end
 
       # :call-seq:

Modified: incubator/buildr/trunk/addon/buildr/jdepend.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/jdepend.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/jdepend.rb (original)
+++ incubator/buildr/trunk/addon/buildr/jdepend.rb Sun Apr  6 00:53:45 2008
@@ -33,7 +33,7 @@
 
       def paths()
         Project.projects.map(&:compile).each(&:invoke).map(&:target).
-          map(&:to_s).select { |path| File.exist?(path) }.map { |path| File.normalize_path(path)
}
+          map(&:to_s).select { |path| File.exist?(path) }.map { |path| FileUtil.normalize_path(path)
}
       end
 
     end

Modified: incubator/buildr/trunk/addon/buildr/nailgun.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/addon/buildr/nailgun.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/addon/buildr/nailgun.rb (original)
+++ incubator/buildr/trunk/addon/buildr/nailgun.rb Sun Apr  6 00:53:45 2008
@@ -319,11 +319,11 @@
 
       def find_buildfile(pwd, candidates, nosearch=false)
         candidates = [candidates].flatten
-        buildfile = candidates.find { |c| File.file?(File.normalize_path(c, pwd)) }
-        return File.normalize_path(buildfile, pwd) if buildfile
+        buildfile = candidates.find { |c| File.file?(File.expand_path(c, pwd)) }
+        return File.expand_path(buildfile, pwd) if buildfile
         return nil if nosearch
         updir = File.dirname(pwd)
-        return nil if File.normalize_path(updir) == File.normalize_path(pwd)
+        return nil if File.expand_path(updir) == File.expand_path(pwd)
         find_buildfile(updir, candidates)
       end
       
@@ -448,7 +448,7 @@
         attr_accessor :runtime
         
         def initialize(path, *requires)
-          @path = File.normalize_path(path)
+          @path = File.expand_path(path)
           @requires = requires.dup
         end
 
@@ -545,7 +545,7 @@
           candidates = [opts.buildfile] if opts.buildfile
           
           path = Util.find_buildfile(ctx.pwd, candidates, opts.nosearch) ||
-            File.normalize_path(candidates.first, ctx.pwd)
+            File.expand_path(candidates.first, ctx.pwd)
           
           if ctx.action == :delete
             nail.out.println "Deleting runtime for #{path}"
@@ -841,8 +841,8 @@
         puts "Starting #{$nailgun_server}"
         $nailgun_server.start_server
 
-        is_win = Config::CONFIG['host_os'] =~ /win/i
-        bin_path = File.normalize_path(installed_bin.to_s.pathmap("%d"))
+        is_win = SystemUtil.win_os?
+        bin_path = FileUtil.normalize_path(installed_bin.to_s.pathmap("%d"))
         bin_name = installed_bin.to_s.pathmap("%f")
 
         puts <<-NOTICE
@@ -862,7 +862,7 @@
         Runtime for #{Rake.application.buildfile} has been cached, this 
         means you can open a terminal inside 
 
-              #{Rake.application.buildfile.pathmap("%d")}
+              #{FileUtil.normalize_path(Rake.application.buildfile.pathmap("%d"))}
 
         Invoke tasks by executing the #{bin_name} program, it takes the
         same parameters you normally use for ``buildr''. 

Modified: incubator/buildr/trunk/lib/buildr/core/addon.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/addon.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/addon.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/addon.rb Sun Apr  6 00:53:45 2008
@@ -34,15 +34,11 @@
     end
 
     def install
-      cmd = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', name
-      cmd .unshift 'sudo' unless Gem.win_platform?
-      sh *cmd
+      SystemUtil.ruby 'install', name, :script => 'gem', :sudo => true
     end
 
     def uninstall
-      cmd = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'uninstall', spec.name, '-v',
spec.version.to_s
-      cmd .unshift 'sudo' unless Gem.win_platform?
-      sh *cmd
+      SystemUtil.ruby 'uninstall', spec.name, '-v', spec.version.to_s, :script => 'gem',
:sudo => true
     end
 
     def upload

Modified: incubator/buildr/trunk/lib/buildr/core/application.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/application.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/application.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/application.rb Sun Apr  6 00:53:45 2008
@@ -188,9 +188,7 @@
         end
         install.each do |spec|
           say "Installing #{spec.full_name} ... " if verbose
-          cmd = Config::CONFIG['ruby_install_name'], '-S', 'gem', 'install', spec.name, '-v',
spec.version.to_s
-          cmd.unshift 'sudo' unless Gem.win_platform? || RUBY_PLATFORM =~ /java/
-          sh *cmd.push(:verbose=>false)
+          SystemUtil.ruby 'install', spec.name, '-v', spec.version.to_s, :script => 'gem',
:sudo => true, :verbose => false
           Gem.source_index.load_gems_in Gem::SourceIndex.installed_spec_directories
         end
         installed += install

Modified: incubator/buildr/trunk/lib/buildr/core/common.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/common.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/common.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/common.rb Sun Apr  6 00:53:45 2008
@@ -19,113 +19,8 @@
 require 'buildr/core/transports'
 require 'open-uri'
 require 'uri/open-sftp'
-require 'rbconfig'
-
-
-module Kernel #:nodoc:
-  # Borrowed from Ruby 1.9.
-  def tap
-    yield self if block_given?
-    self
-  end unless method_defined?('tap')
-end
-
-
-class Symbol #:nodoc:
-  # Borrowed from Ruby 1.9.
-  def to_proc
-    Proc.new{|*args| args.shift.__send__(self, *args)}
-  end unless method_defined?('to_proc')
-end
-
-
-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"] =~ /mswin|windows|cygwin/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
-
-  class << self
-
-    # :call-seq:
-    #   Hash.from_java_properties(string)
-    #
-    # Returns a hash from a string in the Java properties file format. For example:
-    #   str = 'foo=bar\nbaz=fab'
-    #   Hash.from_properties(str)
-    #   => { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
-    def from_java_properties(string)
-      string.gsub(/\\\n/, '').split("\n").select { |line| line =~ /^[^#].*=.*/ }.
-        map { |line| line.gsub(/\\[trnf\\]/) { |escaped| {?t=>"\t", ?r=>"\r", ?n=>"\n",
?f=>"\f", ?\\=>"\\"}[escaped[1]] } }.
-        map { |line| line.split('=') }.
-        inject({}) { |hash, (name, value)| hash.merge(name=>value) }
-    end
-
-  end
-
-  # :call-seq:
-  #   only(keys*) => hash
-  #
-  # Returns a new hash with only the specified keys.
-  #
-  # For example:
-  #   { :a=>1, :b=>2, :c=>3, :d=>4 }.only(:a, :c)
-  #   => { :a=>1, :c=>3 }
-  def only(*keys)
-    keys.inject({}) { |hash, key| has_key?(key) ? hash.merge(key=>self[key]) : hash }
-  end
-
-
-  # :call-seq:
-  #   except(keys*) => hash
-  #
-  # Returns a new hash without the specified keys.
-  #
-  # For example:
-  #   { :a=>1, :b=>2, :c=>3, :d=>4 }.except(:a, :c)
-  #   => { :b=>2, :d=>4 }
-  def except(*keys)
-    (self.keys - keys).inject({}) { |hash, key| hash.merge(key=>self[key]) }
-  end
-
-  # :call-seq:
-  #   to_java_properties => string
-  #
-  # Convert hash to string format used for Java properties file. For example:
-  #   { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
-  #   => foo=bar
-  #      baz=fab
-  def to_java_properties
-    keys.sort.map { |key|
-      value = self[key].gsub(/[\t\r\n\f\\]/) { |escape| "\\" + {"\t"=>"t", "\r"=>"r",
"\n"=>"n", "\f"=>"f", "\\"=>"\\"}[escape] }
-      "#{key}=#{value}"
-    }.join("\n")
-  end
-
-end
 
+require 'buildr/core/util'
 
 module Rake #:nodoc
   class FileList
@@ -161,53 +56,6 @@
     end
   end
 end
-
-
-# Also borrowed from Ruby 1.9.
-class BasicObject #:nodoc:
-  (instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?',
'object_id']).
-    each do |method|
-      undef_method method
-    end
-
-  def self.ancestors
-    [Kernel]
-  end
-end
-
-
-class OpenObject < Hash
-
-  def initialize(source=nil, &block)
-    @hash = Hash.new(&block)
-    @hash.update(source) if source
-  end
-
-  def [](key)
-    @hash[key]
-  end
-
-  def []=(key, value)
-    @hash[key] = value
-  end
-
-  def delete(key)
-    @hash.delete(key)
-  end
-
-  def to_hash
-    @hash.clone
-  end
-
-  def method_missing(symbol, *args)
-    if symbol.to_s =~ /=$/
-      self[symbol.to_s[0..-2].to_sym] = args.first
-    else
-      self[symbol]
-    end
-  end
-end
-
 
 module Buildr
 

Added: incubator/buildr/trunk/lib/buildr/core/util.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/util.rb?rev=645206&view=auto
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/util.rb (added)
+++ incubator/buildr/trunk/lib/buildr/core/util.rb Sun Apr  6 00:53:45 2008
@@ -0,0 +1,238 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+require 'rbconfig'
+
+module Buildr
+  
+  module SystemUtil
+    extend self
+
+    def java_platform?
+      RUBY_PLATFORM =~ /java/
+    end
+
+    # In order to determine if we are running on a windows OS,
+    # prefer this function instead of using Gem.win_platform?.
+    #
+    # Gem.win_platform? only checks the RUBY_PLATFORM global,
+    # that in some cases like when running on JRuby is not 
+    # succifient for our purpose:
+    #
+    # For JRuby, the value for RUBY_PLATFORM will always be 'java'
+    # That's why this function checks on Config::CONFIG['host_os']
+    def win_os?
+      Config::CONFIG['host_os'] =~ /windows|cygwin|bccwin|cygwin|djgpp|mingw|mswin|wince/i
+    end
+
+    # Finds and returns path to executable.  Consults PATH environment variable.
+    # Returns nil if executable not found.
+    def which(name)
+      if win_os?
+        path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| path.gsub('\\', '/')
}.map { |path| "#{path}/#{name}.{exe,bat,com}" }
+      else
+        path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| "#{path}/#{name}" }
+      end
+      FileList[path].existing.first
+    end
+
+    # Runs Ruby with these command line arguments.  The last argument may be a hash,
+    # supporting the following keys:
+    #   :script   -- Runs the specified script (e.g., :script=>'gem')
+    #   :sudo     -- Run as sudo on operating systems that require it.
+    #   :verbose  -- Override Rake's verbose flag.
+    def ruby(*args)
+      options = Hash === args.last ? args.pop : {}
+      cmd = []
+      ruby_bin = FileUtil.normalize_path(Config::CONFIG['ruby_install_name'], Config::CONFIG['bindir'])
+      euid, ruby_uid = Process.uid, File.stat(ruby_bin).uid
+      if options.delete(:sudo) && !win_os? && euid != ruby_uid
+        cmd << 'sudo' << '-u' << '##{ruby_uid}'
+      end
+      cmd << ruby_bin
+      cmd << '-S' << options.delete(:script) if options[:script]
+      Rake.application.sh *cmd.push(*args.flatten).push(options)
+    end
+
+    # :call-seq:
+    #  install_gems(*dependencies) 
+    #
+    def install_gems(*gems)
+      installed = Gem::SourceIndex.from_installed_gems
+      dependencies = gems.map do |gem| 
+        case gem
+        when Gem::Dependency then gem
+        when Array then Gem::Dependency.new(*gem)
+        when String then Gem::Dependency.new(gem, nil)
+        else raise "Invalid gem dependency: #{gem.inspect}"
+        end
+      end
+      dependencies.select { |dep| installed.search(dep.name, dep.version_requirements).empty?
}.each do |dep|
+        puts "Installing #{dep} ..."
+        ruby 'install', dep.name, '-v', dep.version_requirements.to_s, :script=>'gem',
:sudo=>true
+      end
+    end
+  end
+  
+  module FileUtil
+    extend self
+
+    # Just like File.expand_path, but for windows systems it
+    # capitalizes the drive name and ensures backslashes are used
+    #
+    # Use this function when you want to execute a shell command 
+    # with a full path name.
+    def normalize_path(path, *dirs)
+      path = File.expand_path(path, *dirs)
+      if SystemUtil.win_os?
+        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
+
+module Kernel #:nodoc:
+  # Borrowed from Ruby 1.9.
+  def tap
+    yield self if block_given?
+    self
+  end unless method_defined?('tap')
+end
+
+
+class Symbol #:nodoc:
+  # Borrowed from Ruby 1.9.
+  def to_proc
+    Proc.new{|*args| args.shift.__send__(self, *args)}
+  end unless method_defined?('to_proc')
+end
+
+
+# Also borrowed from Ruby 1.9.
+class BasicObject #:nodoc:
+  (instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?',
'object_id']).
+    each do |method|
+      undef_method method
+    end
+
+  def self.ancestors
+    [Kernel]
+  end
+end
+
+
+class OpenObject < Hash
+
+  def initialize(source=nil, &block)
+    @hash = Hash.new(&block)
+    @hash.update(source) if source
+  end
+
+  def [](key)
+    @hash[key]
+  end
+
+  def []=(key, value)
+    @hash[key] = value
+  end
+
+  def delete(key)
+    @hash.delete(key)
+  end
+
+  def to_hash
+    @hash.clone
+  end
+
+  def method_missing(symbol, *args)
+    if symbol.to_s =~ /=$/
+      self[symbol.to_s[0..-2].to_sym] = args.first
+    else
+      self[symbol]
+    end
+  end
+end
+
+class Hash
+
+  class << self
+
+    # :call-seq:
+    #   Hash.from_java_properties(string)
+    #
+    # Returns a hash from a string in the Java properties file format. For example:
+    #   str = 'foo=bar\nbaz=fab'
+    #   Hash.from_properties(str)
+    #   => { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
+    def from_java_properties(string)
+      string.gsub(/\\\n/, '').split("\n").select { |line| line =~ /^[^#].*=.*/ }.
+        map { |line| line.gsub(/\\[trnf\\]/) { |escaped| {?t=>"\t", ?r=>"\r", ?n=>"\n",
?f=>"\f", ?\\=>"\\"}[escaped[1]] } }.
+        map { |line| line.split('=') }.
+        inject({}) { |hash, (name, value)| hash.merge(name=>value) }
+    end
+
+  end
+
+  # :call-seq:
+  #   only(keys*) => hash
+  #
+  # Returns a new hash with only the specified keys.
+  #
+  # For example:
+  #   { :a=>1, :b=>2, :c=>3, :d=>4 }.only(:a, :c)
+  #   => { :a=>1, :c=>3 }
+  def only(*keys)
+    keys.inject({}) { |hash, key| has_key?(key) ? hash.merge(key=>self[key]) : hash }
+  end
+
+
+  # :call-seq:
+  #   except(keys*) => hash
+  #
+  # Returns a new hash without the specified keys.
+  #
+  # For example:
+  #   { :a=>1, :b=>2, :c=>3, :d=>4 }.except(:a, :c)
+  #   => { :b=>2, :d=>4 }
+  def except(*keys)
+    (self.keys - keys).inject({}) { |hash, key| hash.merge(key=>self[key]) }
+  end
+
+  # :call-seq:
+  #   to_java_properties => string
+  #
+  # Convert hash to string format used for Java properties file. For example:
+  #   { 'foo'=>'bar', 'baz'=>'fab' }.to_properties
+  #   => foo=bar
+  #      baz=fab
+  def to_java_properties
+    keys.sort.map { |key|
+      value = self[key].gsub(/[\t\r\n\f\\]/) { |escape| "\\" + {"\t"=>"t", "\r"=>"r",
"\n"=>"n", "\f"=>"f", "\\"=>"\\"}[escape] }
+      "#{key}=#{value}"
+    }.join("\n")
+  end
+
+end

Modified: incubator/buildr/trunk/lib/buildr/java/commands.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/commands.rb?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/commands.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/commands.rb Sun Apr  6 00:53:45 2008
@@ -189,7 +189,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.normalize_path(File.join(home, 'bin', name.to_s))
+        FileUtil.normalize_path(File.join(home, 'bin', name.to_s))
       end
 
       # :call-seq:
@@ -199,7 +199,7 @@
       # each of the artifacts and returns an array of paths.
       def classpath_from(options)
         Buildr.artifacts(options[:classpath] || []).map(&:to_s).
-          map { |t| task(t).invoke; File.normalize_path(t) }
+          map { |t| task(t).invoke; FileUtil.normalize_path(t) }
       end
 
     end

Modified: incubator/buildr/trunk/rakelib/doc.rake
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/rakelib/doc.rake?rev=645206&r1=645205&r2=645206&view=diff
==============================================================================
--- incubator/buildr/trunk/rakelib/doc.rake (original)
+++ incubator/buildr/trunk/rakelib/doc.rake Sun Apr  6 00:53:45 2008
@@ -30,9 +30,9 @@
   gem 'allison'
   rdoc.template = File.expand_path('lib/allison.rb', Gem.loaded_specs['allison'].full_gem_path)
 rescue LoadError
-  say 'Please run rake setup to install the Allison RDoc template'
+  puts 'Please run rake setup to install the Allison RDoc template'
   task 'setup' do
-    ruby 'install', 'allison', :command=>'gem', :sudo=>true
+    ruby 'install', 'allison', :script=>'gem', :sudo=>true
   end
   task 'release:check' do
     fail 'Please run rake setup to install the Allison RDoc template'
@@ -65,9 +65,9 @@
   end
 
 rescue LoadError
-  say 'Please run rake setup to install the Docter document generation library'
+  puts 'Please run rake setup to install the Docter document generation library'
   task 'setup' do
-    ruby 'install', 'docter', :command=>'gem', :sudo=>true
+    ruby 'install', 'docter', :script=>'gem', :sudo=>true
   end
   task 'release:check' do
     fail 'Please run rake setup to install the Docter document generation library'
@@ -75,7 +75,7 @@
 end
 
 
-if which('prince')
+if Object.const_defined?(:Docter) && which('prince')
 
   Docter::Rake.generate 'print',
     Docter.collection($spec.name).using('doc/print.toc.yaml').include('doc/pages', 'LICENSE'),
@@ -105,10 +105,10 @@
 
 namespace 'release' do
   task 'prepare'=>'docs' do
-    say 'Checking that we have site documentation, RDoc and PDF ... '
+    puts 'Checking that we have site documentation, RDoc and PDF ... '
     fail 'No PDF generated, you need to install PrinceXML!' unless File.exist?('site/buildr.pdf')
     fail 'No RDocs in site directory' unless File.exist?('site/rdoc/files/lib/buildr_rb.html')
     fail 'No site documentation in site directory' unless File.exist?('site/index.html')
-    say 'OK'
+    puts 'OK'
   end
 end



Mime
View raw message