buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r1026908 - in /buildr/trunk: CHANGELOG lib/buildr/core/application.rb lib/buildr/core/cc.rb
Date Sun, 24 Oct 2010 22:26:57 GMT
Author: boisvert
Date: Sun Oct 24 22:26:57 2010
New Revision: 1026908

URL: http://svn.apache.org/viewvc?rev=1026908&view=rev
Log:
BUILDR-522 Send notifications when continuous compilation succeeds/fails.

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/core/application.rb
    buildr/trunk/lib/buildr/core/cc.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1026908&r1=1026907&r2=1026908&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sun Oct 24 22:26:57 2010
@@ -7,6 +7,8 @@
           does not exist yet (Gerolf Seitz)
 * Fixed:  BUILDR-543 POMs are installed and uploaded twice when using artifacts
           with classifier
+* Fixed:  BUILDR-522 Send notifications when continuous compilation
+          succeeds/fails.
 
 1.4.3 (2010-10-15)
 * Added:  BUILDR-514 New 'run' local task. http://buildr.apache.org/more_stuff.html#run

Modified: buildr/trunk/lib/buildr/core/application.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/application.rb?rev=1026908&r1=1026907&r2=1026908&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/application.rb (original)
+++ buildr/trunk/lib/buildr/core/application.rb Sun Oct 24 22:26:57 2010
@@ -187,6 +187,20 @@ module Buildr
       @on_failure << block
     end
 
+    # Call on_completion hooks with the given title and message
+    def build_completed(title, message)
+      @on_completion.each do |block|
+        block.call(title, message) rescue nil
+      end
+    end
+
+    # Call on_failure hooks with the given title, message and exception
+    def build_failed(title, message, ex = nil)
+      @on_failure.each do |block|
+        block.call(title, message, ex) rescue nil
+      end
+    end
+
     # :call-seq:
     #   deprecated(message)
     #
@@ -241,9 +255,7 @@ module Buildr
           # On OS X this will load Cocoa and Growl which takes half a second we
           # don't want to measure, so put this after the console message.
           title, message = "Your build has completed", "#{Dir.pwd}\nbuildr #{@top_level_tasks.join('
')}"
-          @on_completion.each do |block|
-            block.call(title, message) rescue nil
-          end
+          build_completed(title, message)
         end
       end
     end
@@ -530,9 +542,7 @@ module Buildr
       rescue Exception => ex
         ex_msg = ex.class.name == "Exception" ? ex.message : "#{ex.class.name} : #{ex.message}"
         title, message = "Your build failed with an error", "#{Dir.pwd}:\n#{ex_msg}"
-        @on_failure.each do |block|
-          block.call(title, message, ex) rescue nil
-        end
+        build_failed(title, message, ex)
         # Exit with error message
         $stderr.puts "Buildr aborted!"
         $stderr.puts $terminal.color(ex_msg, :red)

Modified: buildr/trunk/lib/buildr/core/cc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/cc.rb?rev=1026908&r1=1026907&r2=1026908&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/cc.rb (original)
+++ buildr/trunk/lib/buildr/core/cc.rb Sun Oct 24 22:26:57 2010
@@ -41,18 +41,18 @@ module Buildr
       # we don't want to actually fail if our dependencies don't succede
       begin
         [:compile, 'test:compile'].each { |name| project.task(name).invoke }
-        notify_build_status(true, project)
+        build_completed(project)
       rescue Exception => ex
         $stderr.puts $terminal.color(ex.message, :red)
         $stderr.puts
 
-        notify_build_status(false, project)
+        build_failed(project, ex)
       end
 
       main_dirs = project.compile.sources.map(&:to_s)
       test_dirs = project.task('test:compile').sources.map(&:to_s)
       res_dirs = project.resources.sources.map(&:to_s)
-      
+
       main_ext = Buildr::Compiler.select(project.compile.compiler).source_ext.map(&:to_s)
unless project.compile.compiler.nil?
       test_ext = Buildr::Compiler.select(project.task('test:compile').compiler).source_ext.map(&:to_s)
unless project.task('test:compile').compiler.nil?
 
@@ -102,25 +102,24 @@ module Buildr
             project.task(:resources).filter.run if in_res
             project.task(:compile).invoke if in_main
             project.task('test:compile').invoke if in_test || in_main
+            build_completed(project)
           rescue Exception => ex
             $stderr.puts $terminal.color(ex.message, :red)
+            build_failed(project, ex)
             successful = false
           end
 
-          notify_build_status(successful, project)
           puts $terminal.color("Build complete", :green) if successful
         end
       end
     end
 
-    def notify_build_status(successful, project)
-       if RUBY_PLATFORM =~ /darwin/ && $stdout.isatty && verbose
-         if successful
-           growl_notify('Completed', 'Your build has completed', project.path_to)
-         else
-           growl_notify('Failed', 'Your build has failed with an error', project.path_to)
-         end
-       end
+    def build_completed(project)
+      Buildr.application.build_completed('Compilation successful', project.path_to)
+    end
+
+    def build_failed(project, ex = nil)
+      Buildr.application.build_failed('Compilation failed', project.path_to, ex)
     end
 
     def check_mtime(pattern, old_times)



Mime
View raw message