I'm looking for a way to be able to check if a certain rake task exists from within the Rakefile. I have a task dependency that I only want to include as a dependency if that task is available. In this particular case, the task is only available in a Rails project, but I want my rake tasks to work in a more general Ruby application environment too (not just Rails).
I want to do something like this:
if tasks.includes?('assets:precompile')
task :archive => [:clean, :vendor_deps, 'assets:precompile']
...
end
else
task :archive => [:clean, :vendor_deps]
...
end
end
What is the best way to conditionally include a task dependency in a rake task?