rake
rake copied to clipboard
Is it possible to do on-demand loading of rake tasks?
And if not, would this be a good idea for a pull request?
Okay just to flesh this out - on-demand loading should minimise the time it takes to load and run tasks when there are hundreds of .rake files
It would only apply to namespaces, and there could either be a dynamic loading scheme or a static loading scheme. Both probably useful as we have a ton of legacy stuff
The idea would be something like this:
For static things:
namespace :db => File.expand_path("db.rake", __dir__)
# When looking up a task in namespace :db, this file would be loaded first.
# Could be multiple things like this, all the files would be loaded.
For dynamic things
namespace File.join(__dir__, "tasks")
# When looking up a namespace which could not be found, try to load tasks/#{namespace.gsub(':', '/')}.rake
# If specified, could be used in combination with above static loading.
Open to ideas, suggestions, etc.
If I can just get a sign that this is something that would be accepted/merged (within reason), I'll work on a PR.
This would be extremely useful! I have previously resorted to manually writing logic in Rakefiles to only load the tasks that are necessary based on the top-level tasks passed in by the user.
I've created a PR for this purpose: #339.
@lionelperrin I like your PR. I also use rake a lot, but I decided to try fixing this in a new gem: https://github.com/ioquatix/bake