[Rake-devel] Task#prerequisites and Task#needed?

James M. Lawrence quixoticsycophant at gmail.com
Tue Oct 28 21:17:26 EDT 2008

When I saw commit 995b742d "fixed namespace task list bug" I was
reminded of the problem I had in Drake where Task#prerequisites gave
namespace-unqualified task names

namespace :a do
  task :x
  task :y => :x

task :default do
  p Rake::Task["a:y"].prerequisites   #=> ["x"]
                                      #   should be ["a:x"] ?

Does this work as designed?  I had initially conjectured that you
wanted a task manager to have context-dependent behavior (where the
"x" prereq can mean something different depending on the current
namespace), but it doesn't look like Rake is designed this way.

The other issue was that File#needed? does not look past its immediate prereqs.

file "parent" do
  touch "parent"

file "child" => "parent" do
  touch "child"

file "grandchild" => "child" do
  touch "grandchild"

task :is_grandchild_needed do
  p Rake::Task["grandchild"].needed?

% rake grandchild
(in /Users/jlawrence/test)
touch parent
touch child
touch grandchild
% touch parent
% rake is_grandchild_needed
(in /Users/jlawrence/test)

I hesitate to file bugs because Task#prerequisites and Task#needed?
may be intended for internal use only.

James M. Lawrence

More information about the Rake-devel mailing list