Author: boisvert
Date: Sun Mar  8 16:35:36 2009
New Revision: 751467

URL: http://svn.apache.org/viewvc?rev=751467&view=rev
Log:
Added Scala.version and Scala.version_str; Scala specs now require Scala 2.7.3

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

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=751467&r1=751466&r2=751467&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sun Mar  8 16:35:36 2009
@@ -10,6 +10,7 @@
 * Added:  BUILDR-222: Support Git as a version control system
 * Added   BUILDR-223 Release Task: customizable commit message
 * Added:  Info message "Packaging filename.ext" now displayed for packaging 
tasks
+* Added:  Added Scala.version and Scala.version_str
 * Change: require 'buildr/scala' is now officially required to use Scala 
features
 * Change: Introduced new options from Rake 0.8.3: -I (libdir), -R (rakelib),
           --rules, --no-search, --silent.

Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=751467&r1=751466&r2=751467&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Sun Mar  8 16:35:36 2009
@@ -20,7 +20,21 @@
 
 
 module Buildr::Scala
+
+  class << self
+    def version_str
+      # Scala version string normally looks like "version 2.7.3.final"
+      Java.scala.util.Properties.versionString.sub 'version ', ''
+    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
+    end
+  end
+
   # Scalac compiler:
   #   compile.using(:scalac)
   # Used by default if .scala files are found in the src/main/scala directory 
(or src/test/scala)

Modified: buildr/trunk/spec/scala/scala.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/scala/scala.rb?rev=751467&r1=751466&r2=751467&view=diff
==============================================================================
--- buildr/trunk/spec/scala/scala.rb (original)
+++ buildr/trunk/spec/scala/scala.rb Sun Mar  8 16:35:36 2009
@@ -17,10 +17,16 @@
 require File.join(File.dirname(__FILE__), '../spec_helpers')
 
 describe 'scala' do
+  # Specific version of Scala required for specs
+  required_version = '2.7.3'
+  
   it 'should automatically add the remote scala-tools.org repository' do
     # NOTE: the sandbox environment clears "repositories.remote" so we can't
     #       test for this spec right now.
     #
     # repositories.remote.should 
include('http://scala-tools.org/repo-releases')
   end
+  it "specifications require Scala #{required_version}" do
+    Scala.version.should eql(required_version)
+  end
 end


Reply via email to