Browse files

extension rake task files loaded directly: no need to copy on update.…

… existing extension:update tasks will need to be changed
  • Loading branch information...
1 parent 956ff26 commit 0e4fd7d24380c7a31336c6319c0e772dfab95070 @will-r will-r committed Sep 16, 2011
3 Rakefile
@@ -7,5 +7,6 @@ require 'rdoc/task'
require 'tasks/rails'
unless Rake::Task.task_defined? "radiant:release"
- Dir["#{RADIANT_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
+ Dir["#{RADIANT_ROOT}/lib/tasks/**/*.rake"].sort.each { |taskfile| load taskfile }
+ Radiant::ExtensionPath.rake_task_paths.each { |taskfile| load taskfile }
8 lib/generators/extension/templates/tasks.rake
@@ -24,14 +24,6 @@ namespace :radiant do
mkdir_p RAILS_ROOT + directory, :verbose => false
cp file, RAILS_ROOT + path, :verbose => false
- unless <%= class_name %>.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
- puts "Copying rake tasks from <%= class_name %>"
- local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
- mkdir_p local_tasks_path, :verbose => false
- Dir[File.join <%= class_name %>.root, %w(lib tasks *.rake)].each do |file|
- cp file, local_tasks_path, :verbose => false
- end
- end
desc "Syncs all available translations for this ext to the English ext master"
10 lib/radiant/extension_path.rb
@@ -126,6 +126,14 @@ def metal_paths
+ # Returns a list of all the rake task files found within this extension root.
+ #
+ def rake_task_paths
+ if check_subdirectory("lib/tasks")
+ Dir[File.join("#{path}","lib/tasks/**","*.rake")]
+ end
+ end
# Returns a list of extension subdirectories that should be marked for eager loading. At the moment that
# includes all the controller, model and helper paths. The main purpose here is to ensure that extension
# controllers are loaded before running cucumber features, and there may be a better way to achieve that.
@@ -172,7 +180,7 @@ def enabled_paths{|ep| ep.send(m)}.flatten.compact
- [:locale_paths, :view_paths, :metal_paths].each do |m|
+ [:locale_paths, :view_paths, :metal_paths, :rake_task_paths].each do |m|
define_method(m) do{|ep| ep.send(m)}.flatten.compact.reverse
6 lib/tasks/cucumber.rake
@@ -26,6 +26,12 @@ begin
t.profile = 'wip'
+{:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
+ t.binary = vendored_cucumber_bin
+ t.fork = true # You may get faster startup if you set this to false
+ t.profile = 'rerun'
+ end
desc 'Run all features'
task :all => [:ok, :wip]
19 lib/tasks/extensions.rake
@@ -75,26 +75,11 @@ namespace :spec do
namespace :radiant do
- # TODO: load previously copied tasks just once.
- # If update_all is run multiple times, previously copied tasks will be loaded twice,
- # once from the local copy (RAILS_ROOT/lib/tasks) and once from the gem source.
- task :extensions => :environment do
- Radiant::ExtensionLoader.instance.extensions.each do |extension|
- next if extension.root.starts_with? RAILS_ROOT
- Dir[File.join extension.root, %w(lib tasks *.rake)].sort.each { |task| load task }
- end
- end
namespace :extensions do
desc "Runs update asset task for all extensions"
- task :update_all => [:environment, 'radiant:extensions'] do
- extension_names = { |f| f.to_s.underscore.sub(/_extension$/, '') }
- extension_update_tasks = { |n| "radiant:extensions:#{n}:update" }.select { |t| Rake::Task.task_defined?(t) }
+ task :update_all => [:environment] do
+ extension_update_tasks = { |n| "radiant:extensions:#{n}:update" }.select { |t| Rake::Task.task_defined?(t) }
extension_update_tasks.each {|t| Rake::Task[t].invoke }
-# Load any custom rakefiles from extensions
-[RAILS_ROOT, RADIANT_ROOT].uniq.each do |root|
- Dir[root + '/vendor/extensions/*/lib/tasks/*.rake'].sort.each { |ext| load ext }

1 comment on commit 0e4fd7d

Radiant CMS dev team member

This is probably worthwhile just for making extensions easier to install but it was motivated by a train of thought about script/install extension and the new bundler-based instances. There are still four steps:

  • add a gem line to the bundler
  • run bundle install (which makes rake tasks available)
  • rake radiant:extensions:ext:update
  • rake radiant:extensions:ext:migrate

...but they should be easy to automate.

Could we add a new flag to the extension registry to indicate that the extension is v1-compatible? The gem name should be standard, so we can work that out, and then bundler can do all the installing. Older extensions can still be vendored if you like (but I think that should be strongly discouraged, perhaps by making it not work at all).

One problem: extension update tasks are defined in the the extensions and any that were generated recently (including all the new core extensions) will include the code to copy rake tasks into Rails.root/lib/tasks on update. It doesn't cause huge problems (that we didn't already have), but we will need to fix those individually.

Please sign in to comment.