You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by dj...@apache.org on 2010/04/04 23:04:44 UTC

svn commit: r930748 - /buildr/trunk/lib/buildr/scala/compiler.rb

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