You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

redmine.rake 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2013 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. namespace :redmine do
  18. namespace :attachments do
  19. desc 'Removes uploaded files left unattached after one day.'
  20. task :prune => :environment do
  21. Attachment.prune
  22. end
  23. desc 'Moves attachments stored at the root of the file directory (ie. created before Redmine 2.3) to their subdirectories'
  24. task :move_to_subdirectories => :environment do
  25. Attachment.move_from_root_to_target_directory
  26. end
  27. end
  28. namespace :tokens do
  29. desc 'Removes expired tokens.'
  30. task :prune => :environment do
  31. Token.destroy_expired
  32. end
  33. end
  34. namespace :watchers do
  35. desc 'Removes watchers from what they can no longer view.'
  36. task :prune => :environment do
  37. Watcher.prune
  38. end
  39. end
  40. desc 'Fetch changesets from the repositories'
  41. task :fetch_changesets => :environment do
  42. Repository.fetch_changesets
  43. end
  44. desc 'Migrates and copies plugins assets.'
  45. task :plugins do
  46. Rake::Task["redmine:plugins:migrate"].invoke
  47. Rake::Task["redmine:plugins:assets"].invoke
  48. end
  49. namespace :plugins do
  50. desc 'Migrates installed plugins.'
  51. task :migrate => :environment do
  52. name = ENV['NAME']
  53. version = nil
  54. version_string = ENV['VERSION']
  55. if version_string
  56. if version_string =~ /^\d+$/
  57. version = version_string.to_i
  58. if name.nil?
  59. abort "The VERSION argument requires a plugin NAME."
  60. end
  61. else
  62. abort "Invalid VERSION #{version_string} given."
  63. end
  64. end
  65. begin
  66. Redmine::Plugin.migrate(name, version)
  67. rescue Redmine::PluginNotFound
  68. abort "Plugin #{name} was not found."
  69. end
  70. Rake::Task["db:schema:dump"].invoke
  71. end
  72. desc 'Copies plugins assets into the public directory.'
  73. task :assets => :environment do
  74. name = ENV['NAME']
  75. begin
  76. Redmine::Plugin.mirror_assets(name)
  77. rescue Redmine::PluginNotFound
  78. abort "Plugin #{name} was not found."
  79. end
  80. end
  81. desc 'Runs the plugins tests.'
  82. task :test do
  83. Rake::Task["redmine:plugins:test:units"].invoke
  84. Rake::Task["redmine:plugins:test:functionals"].invoke
  85. Rake::Task["redmine:plugins:test:integration"].invoke
  86. end
  87. namespace :test do
  88. desc 'Runs the plugins unit tests.'
  89. Rake::TestTask.new :units => "db:test:prepare" do |t|
  90. t.libs << "test"
  91. t.verbose = true
  92. t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/unit/**/*_test.rb"
  93. end
  94. desc 'Runs the plugins functional tests.'
  95. Rake::TestTask.new :functionals => "db:test:prepare" do |t|
  96. t.libs << "test"
  97. t.verbose = true
  98. t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/functional/**/*_test.rb"
  99. end
  100. desc 'Runs the plugins integration tests.'
  101. Rake::TestTask.new :integration => "db:test:prepare" do |t|
  102. t.libs << "test"
  103. t.verbose = true
  104. t.pattern = "plugins/#{ENV['NAME'] || '*'}/test/integration/**/*_test.rb"
  105. end
  106. end
  107. end
  108. end
  109. # Load plugins' rake tasks
  110. Dir[File.join(Rails.root, "plugins/*/lib/tasks/**/*.rake")].sort.each { |ext| load ext }