You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/11/06 23:04:27 UTC

svn commit: r711988 - in /incubator/buildr/trunk: CHANGELOG lib/buildr/core/compile.rb lib/buildr/core/filter.rb spec/core/common_spec.rb spec/core/compile_spec.rb

Author: assaf
Date: Thu Nov  6 14:04:19 2008
New Revision: 711988

URL: http://svn.apache.org/viewvc?rev=711988&view=rev
Log:
Fixed: BUILDR-205 resources.target task does nothing when invoked and directory already exists.

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

Modified: incubator/buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/CHANGELOG?rev=711988&r1=711987&r2=711988&view=diff
==============================================================================
--- incubator/buildr/trunk/CHANGELOG (original)
+++ incubator/buildr/trunk/CHANGELOG Thu Nov  6 14:04:19 2008
@@ -22,9 +22,9 @@
           name on Windows).
 * Fixed: BUILDR-194 Buildr always adds 'Manifest-Version' to generated manifest file.
 * Fixed: BUILDR-198 Filter#run always calls mkpath with :verbose.
-* Fixed: BUILDR-199 ArchiveTask#needed uses 'each' with no effect (Ittay
-Dror).
-* Fixed:  BUILDR-201 Sample project is not valid (Alexis Midon).
+* Fixed: BUILDR-199 ArchiveTask#needed uses 'each' with no effect (Ittay Dror).
+* Fixed: BUILDR-201 Sample project is not valid (Alexis Midon).
+* Fixed: BUILDR-205 resources.target task does nothing when invoked and directory already exists.
 
 1.3.3 (2008-10-08)
 * Added:  JtestR support. Implemented pending jtestr specs.

Modified: incubator/buildr/trunk/lib/buildr/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/compile.rb?rev=711988&r1=711987&r2=711988&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/compile.rb Thu Nov  6 14:04:19 2008
@@ -491,11 +491,9 @@
 
     after_define do |project|
       # TODO: Is this necessary?
-      #if project.resources.target
-      #  file project.resources.target.to_s=>project.resources do |task|
-      #    mkpath task.name, :verbose=>false
-      #  end
-      #end
+      if project.resources.target
+        file project.resources.target.to_s=>project.resources
+      end
       if project.compile.target
         # This comes last because the target path is set inside the project definition.
         project.build project.compile.target

Modified: incubator/buildr/trunk/lib/buildr/core/filter.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/core/filter.rb?rev=711988&r1=711987&r2=711988&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/core/filter.rb (original)
+++ incubator/buildr/trunk/lib/buildr/core/filter.rb Thu Nov  6 14:04:19 2008
@@ -169,7 +169,7 @@
           reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }
         files.each do |file|
           src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
-          map[file] = src if !File.exist?(dest) || File.stat(src).mtime > File.stat(dest).mtime
+          map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime
         end
         map
       end
@@ -183,7 +183,7 @@
           if File.directory?(source)
             mkpath dest
           else
-            mkpath File.dirname(dest)
+            mkpath File.dirname(dest), :verbose=>false
             if @mapper.mapper_type
               mapped = @mapper.transform(File.open(source, 'rb') { |file| file.read }, path)
               File.open(dest, 'wb') { |file| file.write mapped }

Modified: incubator/buildr/trunk/spec/core/common_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/core/common_spec.rb?rev=711988&r1=711987&r2=711988&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/core/common_spec.rb (original)
+++ incubator/buildr/trunk/spec/core/common_spec.rb Thu Nov  6 14:04:19 2008
@@ -242,7 +242,9 @@
 describe Buildr::Filter do
   before do
     @filter = Filter.new
-    1.upto(4) { |i| write "src/file#{i}", "file#{i} raw" } # with ${key1} and ${key2}" }
+    1.upto(4) do |i|
+      write "src/file#{i}", "file#{i} raw"
+    end
     @early = Time.now - 1000
   end
 
@@ -456,7 +458,9 @@
     File.mtime('target').should be_close(@early, 10)
   end
 
-  it 'should run only one new files' do
+  it 'should run only on new files' do
+    # Make source files older so they're not copied twice.
+    Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
     @filter.from('src').into('target').run
     @filter.from('src').into('target').using { |file, content| file.should eql('file2') }.run
   end
@@ -466,6 +470,8 @@
   end
 
   it 'should return false when run does not copy any files' do
+    # Make source files older so they're not copied twice.
+    Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
     @filter.from('src').into('target').run
     @filter.from('src').into('target').run.should be(false)
   end

Modified: incubator/buildr/trunk/spec/core/compile_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/core/compile_spec.rb?rev=711988&r1=711987&r2=711988&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/core/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/core/compile_spec.rb Thu Nov  6 14:04:19 2008
@@ -555,6 +555,19 @@
     file('target/resources').should_not exist
   end
 
+  it 'should run from target/resources' do
+    write 'src/main/resources/test'
+    define('foo')
+    lambda { project('foo').resources.target.invoke }.should change { File.exist?('target/resources/test') }.to(true)
+  end
+
+  it 'should run from target/resources when older than sources' do
+    write 'target/resources/test', 'old'
+    write 'src/main/resources/test', 'modified'
+    define('foo')
+    lambda { project('foo').resources.target.invoke }.should change { File.read('target/resources/test') }.to('modified')
+  end
+
   it 'should not be recursive' do
     define('foo') { define 'bar' }
     lambda { project('foo').resources.invoke }.should_not run_task('foo:bar:resources')