Author: donaldp
Date: Thu Oct 24 11:04:16 2013
New Revision: 1535340

URL: http://svn.apache.org/r1535340
Log:
Attempt to work around sequencing issues relating to the order in which 
resources are copied. If a user defines a task that generates assets then these 
assets should be copied first and all the non-filtered resources should come 
after

Modified:
    buildr/trunk/lib/buildr/core/assets.rb

Modified: buildr/trunk/lib/buildr/core/assets.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/assets.rb?rev=1535340&r1=1535339&r2=1535340&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/assets.rb (original)
+++ buildr/trunk/lib/buildr/core/assets.rb Thu Oct 24 11:04:16 2013
@@ -40,6 +40,11 @@ module Buildr #:nodoc:
 
       def initialize(*args) #:nodoc:
         super
+      end
+
+      private
+
+      def add_enhance_actions
         enhance do
           paths = self.paths.flatten.compact
           if paths.size > 0
@@ -49,14 +54,21 @@ module Buildr #:nodoc:
             end.each do |a|
               a.invoke if a.respond_to?(:invoke)
             end.each do |asset|
-              cp_r Dir["#{asset}/*"], "#{name}/"
+              source_dir = asset.to_s
+              Dir["#{source_dir}/*"].each do |f|
+                f = f[source_dir.length + 1, 10000]
+                source = "#{asset}/#{f}"
+                target = "#{name}/#{f}"
+                if !File.exist?(target) || File.mtime(name.to_s) < 
File.mtime(source)
+                  mkdir_p File.dirname(target)
+                  cp source, target
+                end
+              end
             end
           end
         end
       end
 
-      private
-
       def out_of_date?(stamp)
         super ||
           self.paths.any? { |n| n.respond_to?(:needed?) && n.needed? }
@@ -77,6 +89,10 @@ module Buildr #:nodoc:
         project.assets.paths
       end
 
+      after_define do |project|
+        project.assets.send(:add_enhance_actions)
+      end
+
       # Access the asset task
       def assets
         if @assets.nil?


Reply via email to