buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djspie...@apache.org
Subject svn commit: r930748 - /buildr/trunk/lib/buildr/scala/compiler.rb
Date Sun, 04 Apr 2010 21:04:44 GMT
Author: djspiewak
Date: Sun Apr  4 21:04:44 2010
New Revision: 930748

URL: http://svn.apache.org/viewvc?rev=930748&view=rev
Log:
Added fallback case to read Scala version from internal properties file

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=930748&r1=930747&r2=930748&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Sun Apr  4 21:04:44 2010
@@ -28,9 +28,23 @@ module Buildr::Scala
     def version_str
       begin
         # Scala version string normally looks like "version 2.7.3.final"
-        Java.scala.util.Properties.versionString.sub 'version ', ''
+        Java.scala.util.Properties.versionString.sub 'version ', ''         # first try to
read it via the internal API
       rescue
-        nil
+        unless Scalac.scala_home.nil?
+          begin
+            # ...then try to read the value from the properties file
+            props = Zip::ZipFile.open(File.expand_path('lib/scala-library.jar', Scalac.scala_home))
do |zipfile|
+              zipfile.read 'library.properties'
+            end
+
+            md = props.match /version\.number\s*=\s*([^\s]+)/
+            if md.nil? then nil else md[1] end
+          rescue
+            nil
+          end
+        else
+          nil
+        end
       end
     end
 



Mime
View raw message