buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djspie...@apache.org
Subject svn commit: r786677 - /buildr/trunk/lib/buildr/scala/compiler.rb
Date Fri, 19 Jun 2009 21:52:28 GMT
Author: djspiewak
Date: Fri Jun 19 21:52:27 2009
New Revision: 786677

URL: http://svn.apache.org/viewvc?rev=786677&view=rev
Log:
Added fallback DEFAULT_VERSION for when Scala cannot be found

Modified:
    buildr/trunk/lib/buildr/scala/compiler.rb

Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=786677&r1=786676&r2=786677&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Fri Jun 19 21:52:27 2009
@@ -19,18 +19,31 @@
 require 'buildr/packaging'
 
 module Buildr::Scala
-
+  DEFAULT_VERSION = '2.7.5'   # currently the latest (Jun 19, 2009)
+  
   class << self
+    
+    # Retrieves the Scala version string from the 
+    # standard library or nil if Scala is not
+    # available.
     def version_str
-      # Scala version string normally looks like "version 2.7.3.final"
-      Java.scala.util.Properties.versionString.sub 'version ', ''
+      begin
+        # Scala version string normally looks like "version 2.7.3.final"
+        Java.scala.util.Properties.versionString.sub 'version ', ''
+      rescue
+        nil
+      end
     end
     
     def version
-      # any consecutive sequence of numbers followed by dots
-      match = version_str.match(/\d+\.\d[\d\.]*/) or
-        fail "Unable to parse Scala version: #{version_str} "
-      match[0].sub(/.$/, "") # remove trailing dot, if any
+      if version_str
+        # any consecutive sequence of numbers followed by dots
+        match = version_str.match(/\d+\.\d[\d\.]*/) or
+          fail "Unable to parse Scala version: #{version_str} "
+        match[0].sub(/.$/, "") # remove trailing dot, if any
+      else
+        DEFAULT_VERSION
+      end
     end
   end
 



Mime
View raw message