[Rake-devel] Rakefile optional when using a rake directory

Trans transfire at gmail.com
Sat Feb 23 21:52:01 EST 2008

On Sat, Feb 23, 2008 at 8:55 PM, Adam Salter <adam.q.salter at gmail.com> wrote:
> Ummm, a suggestion without a patch is pretty useless.
>  I'm not saying that the suggestion would definately go into the public
>  release anyway, but really... if you have something you want to see,
>  code it and let the admins decide if they want to implement it.

Jim would probably do a better job of it, but just the same this
should do, in rake.rb:

  class Application

    # ADD 'rake' to end of list
    DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb',
'Rakefile.rb', 'rake'].freeze

    def raw_load_rakefile # :nodoc:
      here = Dir.pwd
      while ! have_rakefile
        if Dir.pwd == here || options.nosearch
          fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})"
        here = Dir.pwd
      puts "(in #{Dir.pwd})" unless options.silent
      $rakefile = @rakefile
      # -- NEW CODE
      if File.directory?(@rakefile)
        options.rakelib |= @rakefile
        @rakefile = ''
      # -- END NEW CODE
      load File.expand_path(@rakefile) if @rakefile != ''
      options.rakelib.each do |rlib|
        Dir["#{rlib}/*.rake"].each do |name| add_import name end

I'm not sure why the possibility for @rakefile == '' even exists, but
I utilized it for my patch. If for some reason that's not appropriate,
then extending the if-clause to include the loading of the rakefile in
an else-clause would suffice.


More information about the Rake-devel mailing list