Author: boisvert
Date: Wed Sep 14 13:24:01 2011
New Revision: 1170605

URL: http://svn.apache.org/viewvc?rev=1170605&view=rev
Log:
BUILDR-611 Buildr should not unnecessarily recompile Java files explicitly 
added to compile.from

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

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1170605&r1=1170604&r2=1170605&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Sep 14 13:24:01 2011
@@ -1,4 +1,6 @@
 1.4.7 (Pending)
+* Fixed:  BUILDR-611 Buildr should not unnecessarily recompile Java files
+          explicitly added to compile.from
 * Added:  ScalaTest now automatically loads the Mockito library
 * Fixed:  scaladoc generation with scala 2.9.x
 * Change: Stop pretty printing the Intellij IDEA project files to avoid IDEA 
breaking

Modified: buildr/trunk/lib/buildr/core/compile.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/compile.rb?rev=1170605&r1=1170604&r2=1170605&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/compile.rb (original)
+++ buildr/trunk/lib/buildr/core/compile.rb Wed Sep 14 13:24:01 2011
@@ -46,9 +46,9 @@ module Buildr
       def compilers
         @compilers ||= []
       end
-      
+
       private
-      
+
       # Only used by our specs.
       def compilers=(compilers)
         @compilers = compilers
@@ -87,8 +87,8 @@ module Buildr
           paths = task.sources + [sources].flatten.map { |src| 
Array(project.path_to(:source, task.usage, src.to_sym)) }
           paths.flatten!
           ext_glob = Array(source_ext).join(',')
-          
-          paths.each { |path| 
+
+          paths.each { |path|
             Find.find(path) {|found|
               if (!File.directory?(found)) && 
found.match(/.*\.#{Array(source_ext).join('|')}/)
                 return true
@@ -187,7 +187,7 @@ module Buildr
           else
             # try to extract package name from .java or .scala files
             if ['.java', '.scala', '.groovy'].include? File.extname(source)
-              package = findFirst(source, /^\s*package\s+(\S+)\s*;?\s*$/)
+              package = findFirst(source, /^\s*package\s+([^\s;]+)\s*;?\s*/)
               map[source] = package ? File.join(target, package[1].gsub('.', 
'/'), File.basename(source).ext(target_ext)) : target
             elsif
               map[source] = target

Modified: buildr/trunk/spec/core/compile_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/core/compile_spec.rb?rev=1170605&r1=1170604&r2=1170605&view=diff
==============================================================================
--- buildr/trunk/spec/core/compile_spec.rb (original)
+++ buildr/trunk/spec/core/compile_spec.rb Wed Sep 14 13:24:01 2011
@@ -413,6 +413,17 @@ describe Buildr::CompileTask, '#invoke' 
       lambda { compile.from('sources').invoke }.should 
raise_error(RuntimeError, /no compiler selected/i)
     end
   end
+
+  it 'should not unnecessarily recompile files explicitly added to compile 
list (BUILDR-611)' do
+    mkpath 'src/other'
+    write 'src/other/Foo.java', 'package foo; public class Foo {}'
+    compile_task.from FileList['src/other/**.java']
+    mkpath 'target/classes/foo'
+    touch 'target/classes/foo/Foo.class'
+    File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
+    compile_task.invoke
+    File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
+  end
 end
 
 


Reply via email to