buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject svn commit: r657901 - in /incubator/buildr/trunk: CHANGELOG Rakefile lib/buildr/core/compile.rb lib/buildr/core/filter.rb spec/common_spec.rb spec/test_spec.rb
Date Mon, 19 May 2008 18:32:40 GMT
Author: assaf
Date: Mon May 19 11:32:40 2008
New Revision: 657901

URL: http://svn.apache.org/viewvc?rev=657901&view=rev
Log:
Fixed: BUILDR-75 Filter now runs if there's a target directory, even if
there are no source files to copy over, since everyone else just checks
resources.target for existence before depending on it.

Modified:
    incubator/buildr/trunk/CHANGELOG
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/lib/buildr/core/compile.rb
    incubator/buildr/trunk/lib/buildr/core/filter.rb
    incubator/buildr/trunk/spec/common_spec.rb
    incubator/buildr/trunk/spec/test_spec.rb

Modified: incubator/buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Mon May 19 11:32:40 2008
@@ -7,6 +7,9 @@
 (only applicable when forking).
 * Fixed: BUILDR-70 JUnit not passing environment variables from the
 :environment option.
+* Fixed: BUILDR-75 Filter now runs if there's a target directory, even if
+there are no source files to copy over, since everyone else just checks
+resources.target for existence before depending on it.
 
 1.3.0 (2008-04-25)
 * Added: Testing with EasyB (Nicolas Modrzyk).

Modified: incubator/buildr/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Mon May 19 11:32:40 2008
@@ -28,7 +28,7 @@
       spec.add_dependency 'ci_reporter', '1.5.1' # must come after builder dependency
     else
       # Place first on the dependency list, otherwise AntWrap picks the latest RJB.
-      spec.dependencies.unshift Gem::Dependency.new('rjb', '=>1.1.0', '<= 1.1.2'])
+      spec.dependencies.unshift Gem::Dependency.new('rjb', ['>=1.1.0', '<= 1.1.2'])
     end
     spec
   end

Modified: incubator/buildr/trunk/lib/buildr/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/compile.rb?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/compile.rb Mon May 19 11:32:40 2008
@@ -403,7 +403,7 @@
       @filter = Buildr::Filter.new
       @filter.using Buildr.settings.profile['filter'] if Hash === Buildr.settings.profile['filter']
       enhance do
-        filter.run if target && !sources.empty?
+        filter.run if target
       end
     end
 

Modified: incubator/buildr/trunk/lib/buildr/core/filter.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/filter.rb?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/filter.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/filter.rb Mon May 19 11:32:40 2008
@@ -83,7 +83,7 @@
     # For example:
     #   filter.from('src').into('target').using('build'=>Time.now)
     def into(dir)
-      @target = file(File.expand_path(dir.to_s)) { |task| run if target == task &&
!sources.empty? }
+      @target = file(File.expand_path(dir.to_s)) { |task| run if target == task }
       self
     end
 
@@ -160,7 +160,6 @@
     #
     # Runs the filter.
     def run
-      raise 'No source directory specified, where am I going to find the files to filter?'
if sources.empty?
       sources.each { |source| raise "Source directory #{source} doesn't exist" unless File.exist?(source.to_s)
}
       raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
 
@@ -176,10 +175,10 @@
         map
       end
         
+      mkpath target.to_s
       return false if copy_map.empty?
 
       verbose(Buildr.application.options.trace || false) do
-        mkpath target.to_s
         copy_map.each do |path, source|
           dest = File.expand_path(path, target.to_s)
           if File.directory?(source)
@@ -198,7 +197,7 @@
                 mapped = regexp_mapper(content) { |key| mapping[key] }
               end
                 #gsub(/\$\{[^}]*\}/) { |str| mapping[str[2..-2]] || str }
-              File.open(dest, 'wb') { |file| file.write mapped }
+                File.open(dest, 'wb') { |file| file.write mapped }
             when nil # No mapping.
               cp source, dest
               File.chmod(0664, dest)
@@ -207,7 +206,7 @@
             end
           end
         end
-        touch target.to_s 
+        touch target.to_s
       end
       true
     end

Modified: incubator/buildr/trunk/spec/common_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/common_spec.rb?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/common_spec.rb (original)
+++ incubator/buildr/trunk/spec/common_spec.rb Mon May 19 11:32:40 2008
@@ -411,10 +411,6 @@
     @filter.from('src').into('target').run.should be(false)
   end
 
-  it 'should fail is source directory not set' do
-    lambda { Filter.new.into('target').run }.should raise_error(RuntimeError, /No source
directory/)
-  end
-
   it 'should fail if source directory doesn\'t exist' do
     lambda { Filter.new.from('srced').into('target').run }.should raise_error(RuntimeError,
/doesn't exist/)
   end

Modified: incubator/buildr/trunk/spec/test_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/test_spec.rb?rev=657901&r1=657900&r2=657901&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/test_spec.rb (original)
+++ incubator/buildr/trunk/spec/test_spec.rb Mon May 19 11:32:40 2008
@@ -458,6 +458,7 @@
 describe Buildr::Project, 'test:resources' do
   it 'should ignore resources unless they exist' do
     define('foo').test.resources.sources.should be_empty
+    project('foo').test.resources.target.should be_nil
   end
 
   it 'should pick resources from src/test/resources if found' do
@@ -471,6 +472,11 @@
     file('targeted/test/resources/foo').should contain('Foo')
   end
 
+  it 'should create target directory even if no files to copy' do
+    define('foo').test.resources.filter.into('resources')
+    lambda { file(File.expand_path('resources')).invoke }.should change { File.exist?('resources')
}.to(true)
+  end
+
   it 'should execute alongside compile task' do
     task 'action'
     define('foo') { test.resources { task('action').invoke } }



Mime
View raw message