Skip to content
Browse files

Deprecate toplevel plugins tasks in favor of lib/tasks for Rails 3 fo…

…rward compat
  • Loading branch information...
1 parent b06e5dc commit ed7322f33622023e7075b3738dc82ed3d78f3c9d @jeremy jeremy committed
View
4 railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb
@@ -13,7 +13,7 @@ def manifest
m.class_collisions class_name
m.directory "#{plugin_path}/lib"
- m.directory "#{plugin_path}/tasks"
+ m.directory "#{plugin_path}/lib/tasks"
m.directory "#{plugin_path}/test"
m.template 'README', "#{plugin_path}/README"
@@ -23,7 +23,7 @@ def manifest
m.template 'install.rb', "#{plugin_path}/install.rb"
m.template 'uninstall.rb', "#{plugin_path}/uninstall.rb"
m.template 'plugin.rb', "#{plugin_path}/lib/#{file_name}.rb"
- m.template 'tasks.rake', "#{plugin_path}/tasks/#{file_name}_tasks.rake"
+ m.template 'tasks.rake', "#{plugin_path}/lib/tasks/#{file_name}.rake"
m.template 'unit_test.rb', "#{plugin_path}/test/#{file_name}_test.rb"
m.template 'test_helper.rb', "#{plugin_path}/test/test_helper.rb"
if @with_generator
View
7 railties/lib/tasks/rails.rb
@@ -4,6 +4,11 @@
Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
# Load any custom rakefile extensions
-Dir["#{RAILS_ROOT}/vendor/plugins/*/tasks/**/*.rake"].sort.each { |ext| load ext }
+deprecated_paths = Dir["#{RAILS_ROOT}/vendor/plugins/*/tasks/**/*.rake"].sort
+if deprecated_paths.any?
+ plugins = deprecated_paths.map { |p| $1 if p =~ %r((vendor/plugins/[^/]+/tasks)) }.compact
+ ActiveSupport::Deprecation.warn "Rake tasks in #{plugins.to_sentence} are deprecated. Use lib/tasks instead."
+ deprecated_tasks.each { |ext| load ext }
+end
Dir["#{RAILS_ROOT}/vendor/plugins/*/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }

0 comments on commit ed7322f

Please sign in to comment.
Something went wrong with that request. Please try again.