Sha256: 2a11c41a016a5d4b146ea59d58e41de40b91c686b35570f367dafba14b0d7c2c

Contents?: true

Size: 1.04 KB

Versions: 93

Compression:

Stored size: 1.04 KB

Contents

require 'rake'
module Rake
  class TaskNotFound < StandardError; end
  def self.run(rakefile, dir, task)
    old_pwd = FileUtils.pwd

    Rake::FileTask.module_eval do
      if not self.respond_to? :old_define_task
        class << self
          alias_method :old_define_task, :define_task
        end

        def self.define_task(file, *args, &block)
          @@files ||= []
          @@files << file
          old_define_task(file, *args, &block)
        end
      end

      def self.files
        @@files
      end
      
      def self.clear_files
        @@files = []
      end
    end

    Rake::Task.clear
    Rake::FileTask.clear_files

    if block_given?
      yield
    else
      load rakefile
    end

    raise TaskNotFound if Rake::Task[task].nil?

    t = nil
    #pid = Process.fork{
    begin
      Misc.in_dir(dir) do
        Rake::Task[task].invoke

        Rake::Task.clear
        Rake::FileTask.clear_files
      end
    rescue
      Log.error "Error in rake: #{$!.message}"
      raise $!
    end
    #}
    #Process.wait(pid)

  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
rbbt-util-5.13.36 lib/rbbt/resource/rake.rb
rbbt-util-5.13.35 lib/rbbt/resource/rake.rb
rbbt-util-5.13.34 lib/rbbt/resource/rake.rb
rbbt-util-5.13.33 lib/rbbt/resource/rake.rb
rbbt-util-5.13.32 lib/rbbt/resource/rake.rb
rbbt-util-5.13.31 lib/rbbt/resource/rake.rb
rbbt-util-5.13.30 lib/rbbt/resource/rake.rb
rbbt-util-5.13.29 lib/rbbt/resource/rake.rb
rbbt-util-5.13.28 lib/rbbt/resource/rake.rb
rbbt-util-5.13.27 lib/rbbt/resource/rake.rb
rbbt-util-5.13.26 lib/rbbt/resource/rake.rb
rbbt-util-5.13.25 lib/rbbt/resource/rake.rb
rbbt-util-5.13.24 lib/rbbt/resource/rake.rb
rbbt-util-5.13.23 lib/rbbt/resource/rake.rb
rbbt-util-5.13.22 lib/rbbt/resource/rake.rb
rbbt-util-5.13.21 lib/rbbt/resource/rake.rb
rbbt-util-5.13.20 lib/rbbt/resource/rake.rb
rbbt-util-5.13.19 lib/rbbt/resource/rake.rb
rbbt-util-5.13.18 lib/rbbt/resource/rake.rb
rbbt-util-5.13.17 lib/rbbt/resource/rake.rb