Is there a command line switc开发者_如何转开发h I'm missing?
At the moment I'm having to do this:
#task :install => :build do
task :install do
end
I seem to have solved this problem by simply adding extra tasks in the format "taskname_no_prerequisites". So for example in the code below executing "rake install_no_prerequisites" would not cause "build" to be executed.
desc "Build"
task :build do
puts "BUILDING..."
end
desc "Install"
task :install => :build do
puts "INSTALLING..."
end
Rake::Task::tasks.each do |task|
desc "#{task} without prerequisites"
task "#{task}_no_prerequisites".to_sym do
task.invoke_without_prerequisites
end
end
module Rake
class Task
def invoke_without_prerequisites
execute
end
end
end
if you define a dependency on a task, it will always be run first. However, you can create your tasks individually and then aggregate them together with another task, like this:
task :build do
...
end
task :install do
...
end
task :go => [:build, :install]
and then you can call the build or install tasks independently, or run the sequence with the go task.
rake build
rake install
rake go
i do this a lot, actually. it makes it very convenient for me to run individual steps when i want to, and have the larger sequence of steps when i need them.
精彩评论