diff --git a/CHANGES b/CHANGES index 992f53b41..c4929ed81 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ = Rake Changelog +== Version 0.9.1 + +* Added deprecation warnings to the Rake DSL methods. + == Version 0.9.0 * *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.) are diff --git a/bin/rake b/bin/rake index 00005330c..941a021cb 100755 --- a/bin/rake +++ b/bin/rake @@ -25,9 +25,10 @@ #++ begin - require 'rake' -rescue LoadError require 'rubygems' - require 'rake' +rescue LoadError end + +require 'rake' + Rake.application.run diff --git a/doc/release_notes/rake-0.9.1.rdoc b/doc/release_notes/rake-0.9.1.rdoc new file mode 100644 index 000000000..70be8b568 --- /dev/null +++ b/doc/release_notes/rake-0.9.1.rdoc @@ -0,0 +1,52 @@ += Rake 0.9.1 Released + +Rake version 0.9.1 has a number of bug fixes and enhancments (see +below for more details). Additionally, the internals have be slightly +restructured and improved. + +== Changes + +Rake 0.9.1 adds back the global DSL methods, but with deprecation +messages. This allows Rake 0.9.1 to be used with older rakefiles with +warning messages. + +== What is Rake + +Rake is a build tool similar to the make program in many ways. But +instead of cryptic make recipes, Rake uses standard Ruby code to +declare tasks and dependencies. You have the full power of a modern +scripting language built right into your build tool. + +== Availability + +The easiest way to get and install rake is via RubyGems ... + + gem install rake (you may need root/admin privileges) + +Otherwise, you can get it from the more traditional places: + +Home Page:: http://rake.rubyforge.org/ +Download:: http://rubyforge.org/project/showfiles.php?group_id=50 +GitHub:: git://github.com/jimweirich/rake.git + +== Thanks + +As usual, it was input from users that drove a alot of these changes. The +following people either contributed patches, made suggestions or made +otherwise helpful comments. Thanks to ... + +* James M. Lawrence (quix) +* Roger Pack +* Cezary Baginski +* Sean Scot August Moon +* R.T. Lechow +* Alex Chaffee +* James Tucker +* Matthias Lüdtke +* Santiago Pastorino + +Also, bit thanks to Eric Hodel for assisting with getting this release +out the door (where "assisting" includes, but is not by any means +limited to, "pushing" me to get it done). + +-- Jim Weirich diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb deleted file mode 100644 index 88fc8e2ea..000000000 --- a/lib/rake/dsl.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'rake' -include Rake::DSL diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index 47762f67f..e49d0d77d 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -12,6 +12,8 @@ module DSL private(*FileUtils.instance_methods(false)) private(*FileUtilsExt.instance_methods(false)) + private + # Declare a basic task. # # Example: @@ -137,7 +139,24 @@ def import(*fns) end end + module DeprecatedObjectDSL + dsl = Object.new.extend DSL + DSL.private_instance_methods(false).each do |name| + define_method name do |*args, &block| + unless @rake_dsl_warning + $stderr.puts "WARNING: Global access to Rake DSL methods is deprecated. Please Include" + $stderr.puts " ... Rake::DSL into classes and modules which use the Rake DSL methods." + @rake_dsl_warning = true + end + $stderr.puts "WARNING: DSL method #{self.class}##{name} called at #{caller.first}" + dsl.send(name, *args, &block) + end + private name + end + end + extend FileUtilsExt end self.extend Rake::DSL +include Rake::DeprecatedObjectDSL diff --git a/lib/rake/version.rb b/lib/rake/version.rb index afec61fc4..4f3a76b1a 100644 --- a/lib/rake/version.rb +++ b/lib/rake/version.rb @@ -3,7 +3,7 @@ module Version NUMBERS = [ MAJOR = 0, MINOR = 9, - BUILD = 0, + BUILD = 1, DRAKE_MAJOR = 0, DRAKE_MINOR = 3, DRAKE_BUILD = 0, diff --git a/test/data/access/Rakefile b/test/data/access/Rakefile index 7052abac2..c064cace9 100644 --- a/test/data/access/Rakefile +++ b/test/data/access/Rakefile @@ -14,7 +14,9 @@ task :work do end end -task :obj do +# TODO: remove `disabled_' when DeprecatedObjectDSL removed +task :obj +task :disabled_obj do begin Object.new.instance_eval { task :xyzzy } puts "BAD:D Rake DSL are polluting objects" diff --git a/test/test_rake_dsl.rb b/test/test_rake_dsl.rb index 1c8050355..fc7b57fce 100644 --- a/test/test_rake_dsl.rb +++ b/test/test_rake_dsl.rb @@ -28,14 +28,26 @@ def name.to_str refute_nil Rake::Task["bob:t"] end - def test_dsl_not_toplevel_by_default - actual = TOPLEVEL_BINDING.instance_eval { defined?(task) } - assert_nil actual + class Foo + def initialize + task :foo_deprecated_a => "foo_deprecated_b" do + print "a" + end + file "foo_deprecated_b" do + print "b" + end + end end - def test_dsl_toplevel_when_require_rake_dsl - ruby '-I./lib', '-rrake/dsl', '-e', 'task(:x) { }', :verbose => false - - assert $?.exitstatus + def test_deprecated_object_dsl + out, err = capture_io do + Foo.new + Rake.application.invoke_task :foo_deprecated_a + end + assert_equal("ba", out) + assert_match(/deprecated/, err) + assert_match(/Foo\#task/, err) + assert_match(/Foo\#file/, err) + assert_match(/test_rake_dsl\.rb:\d+/, err) end end