2
votes

I'm using a build system which defines a number of rake targets, including this one:

task :test => [:all]

This seems incorrect to me, and so I defined my own rake tasks like so:

task :test => [:spec]
task :all => [:test, :build]
task :release => [:all]
task :default => [:release]

However, now I'm getting this error when I try to build my package:

Circular dependency detected: TOP => default => all => test => all
Tasks: TOP => default => all => test
BUILD FAILED

I've come to realize that defining a rake task (or dependencies for a rake task) just appends those tasks/dependencies to the task definition! This is driving me crazy! Why can't I redefine my rake tasks as I see fit?! Is there any way to overwrite a rake task, and/or to overwrite the dependencies of a rake task?

1
I found this post from 2008, but it seems like such a hack! There must be a cleaner way to do this, right? blog.jayfields.com/2008/02/rake-task-overwriting.html - Dasmowenator

1 Answers

1
votes

Use this before you define your task:

Rake::Task[:test].clear

This is implemented in the rake gem, file lib/rake/task.rb You can see it also supports clear_prerequisites, clear_actions, clear_comments, clear_args as well (clear does all four things).