You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2011/05/27 23:55:21 UTC

svn commit: r1128480 - in /buildr/trunk: ./ doc/ lib/buildr/scala/ spec/ spec/scala/

Author: boisvert
Date: Fri May 27 21:55:20 2011
New Revision: 1128480

URL: http://svn.apache.org/viewvc?rev=1128480&view=rev
Log:
* Support for Scala 2.9.0+
* Scala 2.9.0-1 is now default, along with ScalaCheck 1.9, ScalaTest 1.4.1 and Specs 1.6.8.
* ScalaCheck, ScalaTest and Specs now default to sane versions when using older Scala versions.
(with help from Alexis Midon)

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/doc/languages.textile
    buildr/trunk/lib/buildr/scala/bdd.rb
    buildr/trunk/lib/buildr/scala/compiler.rb
    buildr/trunk/lib/buildr/scala/doc.rb
    buildr/trunk/lib/buildr/scala/tests.rb
    buildr/trunk/spec/sandbox.rb
    buildr/trunk/spec/scala/bdd_spec.rb
    buildr/trunk/spec/scala/compiler_spec.rb
    buildr/trunk/spec/scala/doc_spec.rb
    buildr/trunk/spec/scala/scala.rb
    buildr/trunk/spec/scala/tests_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Fri May 27 21:55:20 2011
@@ -1,4 +1,9 @@
 1.4.6 (Pending)
+* Added:  Support for Scala 2.9.0+ (with help of Alexis Midon)
+* Change: Scala 2.9.0-1 is now default, along with ScalaCheck 1.9, ScalaTest 1.4.1
+          and Specs 1.6.8. 
+* Change: ScalaCheck, ScalaTest and Specs now default to sane versions when using
+          older Scala versions.
 * Fixed:  BUILDR-583 Update jruby install to use jruby version 1.6.1 (Alexis Midon)
 * Fixed:  BUILDR-582 Revert the name change for the task to generate Intellij
           project files to 'idea'

Modified: buildr/trunk/doc/languages.textile
URL: http://svn.apache.org/viewvc/buildr/trunk/doc/languages.textile?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/doc/languages.textile (original)
+++ buildr/trunk/doc/languages.textile Fri May 27 21:55:20 2011
@@ -170,7 +170,7 @@ Before using Scala, you must first @requ
 require 'buildr/scala'
 {% endhighlight %}
 
-By default, Buildr will attempt to use the latest stable release of Scala, which is currently Scala 2.8.0 as of July 2010.  Of course you can configure a specific version of Scala for your project by adding the following entry in @build.yaml@:
+By default, Buildr will attempt to use the latest stable release of Scala, which is currently Scala 2.9.0 as of May 2011.  Of course you can configure a specific version of Scala for your project by adding the following entry in @build.yaml@:
 
 {% highlight yaml %}
 scala.version: 2.8.0.Beta1  # Pick your version
@@ -210,11 +210,11 @@ When using the Scala compiler, if you do
 The Scala compiler supports the following options:
 
 |_. Option        |_. Usage |
-| @:debug@        | Generates bytecode with debugging information.  You can also override this by setting the environment variable @debug@ to @off@. |
+| @:debug@        | If true, generates bytecode with debugging information. Scala 2.9 also accepts: none,source,line,vars,notc. |
 | @:deprecation@  | If true, shows deprecation messages.  False by default. |
+| @:make@         | Make strategy to be used by the compiler (e.g. @:make=>'transitive'@). *Scala 2.8 only* |
 | @:optimise@     | Generates faster bytecode by applying optimisations to the program. |
 | @:other@        | Array of options passed to the compiler (e.g. @:other=>'-Xprint-types'@). |
-| @:make@         | Make strategy to be used by the compiler (e.g. @:make=>'transitive'@).  *Scala 2.8 only* |
 | @:target@       | Bytecode compatibility (e.g. '1.4'). |
 | @:warnings@     | Issue warnings when compiling.  True when running in verbose mode. |
 | @:javac@        | A hash of options passed to the @javac@ compiler verbatim. |

Modified: buildr/trunk/lib/buildr/scala/bdd.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/bdd.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/bdd.rb (original)
+++ buildr/trunk/lib/buildr/scala/bdd.rb Fri May 27 21:55:20 2011
@@ -32,21 +32,34 @@ module Buildr::Scala
     @lang = :scala
     @bdd_dir = :spec
 
-    VERSION = '1.6.6'
+    VERSION = case
+      when Buildr::Scala.version?("2.8.0")
+        '1.6.5'
+      when Buildr::Scala.version?("2.8.1")
+        '1.6.8'
+      else
+        '1.6.8'
+    end
+
 
     class << self
       def version
-        Buildr.settings.build['scala.specs'] || VERSION
+        custom = Buildr.settings.build['scala.specs']
+        (custom =~ /:/) ? Buildr.artifact(custom).version : VERSION
+      end
+
+      def specs
+        custom = Buildr.settings.build['scala.specs']
+        [ (custom =~ /:/) ? custom : "org.scala-tools.testing:#{artifact}:jar:#{version}" ]
       end
 
       def artifact
-        Buildr.settings.build['scala.specs.artifact'] || "specs_#{Buildr::Scala.version}"
+        Buildr.settings.build['scala.specs.artifact'] || "specs_#{Buildr::Scala.version_without_build}"
       end
 
       def dependencies
         unless @dependencies
           super
-          specs = (version =~ /:/) ? [version] : ["org.scala-tools.testing:#{artifact}:jar:#{version}"]
           # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies
           @dependencies |= [ File.join(File.dirname(__FILE__)) ] + specs +
                            Check.dependencies + JUnit.dependencies + Scalac.dependencies

Modified: buildr/trunk/lib/buildr/scala/compiler.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/compiler.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/compiler.rb (original)
+++ buildr/trunk/lib/buildr/scala/compiler.rb Fri May 27 21:55:20 2011
@@ -19,7 +19,7 @@ require 'buildr/core/compile'
 require 'buildr/packaging'
 
 module Buildr::Scala
-  DEFAULT_VERSION = '2.8.1'
+  DEFAULT_VERSION = '2.9.0-1'
 
   class << self
 
@@ -59,13 +59,15 @@ module Buildr::Scala
       Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION
     end
 
-    def compatible_28?
-      major, minor = version.match(/^(\d)\.(\d)/).to_a[1,2]
-      if major && minor
-        (major.to_i == 2 && minor.to_i >= 8) || (major.to_i > 2)
-      else
-        false
-      end
+    # check if version matches any of the given prefixes
+    def version?(*v)
+      v.any? { |v| version.index(v.to_s) == 0 }
+    end
+
+    # returns Scala version without build number.
+    # e.g.  "2.9.0-1" => "2.9.0"
+    def version_without_build
+      version.split('-')[0]
     end
   end
 
@@ -156,17 +158,17 @@ module Buildr::Scala
       options[:warnings] = verbose if options[:warnings].nil?
       options[:deprecation] ||= false
       options[:optimise] ||= false
-      options[:make] ||= :transitivenocp if Scala.compatible_28?
+      options[:make] ||= :transitivenocp if Scala.version? 2.8
       options[:javac] ||= {}
 
       @java = Javac.new(project, options[:javac])
     end
 
     def compile(sources, target, dependencies) #:nodoc:
-      check_options(options, OPTIONS + (Scala.compatible_28? ? [:make] : []))
+      check_options(options, OPTIONS + (Scala.version?(2.8) ? [:make] : []))
 
       java_sources = java_sources(sources)
-      enable_dep_tracing = Scala.compatible_28? && java_sources.empty?
+      enable_dep_tracing = Scala.version?(2.8) && java_sources.empty?
 
       dependencies.unshift target if enable_dep_tracing
 
@@ -226,7 +228,11 @@ module Buildr::Scala
       args = []
       args << "-nowarn" unless options[:warnings]
       args << "-verbose" if trace?(:scalac)
-      args << "-g" if options[:debug]
+      if options[:debug] == true
+        args << (Scala.version?(2.7, 2.8) ? "-g" : "-g:vars")
+      elsif options[:debug]
+        args << "-g:#{options[:debug]}"
+      end
       args << "-deprecation" if options[:deprecation]
       args << "-optimise" if options[:optimise]
       args << "-target:jvm-" + options[:target].to_s if options[:target]

Modified: buildr/trunk/lib/buildr/scala/doc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/doc.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/doc.rb (original)
+++ buildr/trunk/lib/buildr/scala/doc.rb Fri May 27 21:55:20 2011
@@ -26,7 +26,7 @@ module Buildr
       after_define(:scaladoc => :doc) do |project|
         if project.doc.engine? Scaladoc
           options = project.doc.options
-          key = Scala.compatible_28? ? "doc-title".to_sym : :windowtitle
+          key = Scala.version?(2.7) ? :windowtitle : "doc-title".to_sym
           options[key] = (project.comment || project.name) unless options[key]
         end
       end

Modified: buildr/trunk/lib/buildr/scala/tests.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/tests.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/tests.rb (original)
+++ buildr/trunk/lib/buildr/scala/tests.rb Fri May 27 21:55:20 2011
@@ -23,7 +23,16 @@ require 'buildr/java/tests'
 module Buildr::Scala
   # Scala::Check is available when using Scala::Test or Scala::Specs
   module Check
-    VERSION = '1.8'
+    VERSION = case
+      when Buildr::Scala.version?("2.7")
+        '1.6'
+      when Buildr::Scala.version?("2.8.0")
+        '1.7'
+      when Buildr::Scala.version?("2.8.1")
+        '1.8'
+      else
+        '1.9'
+    end
 
     class << self
       def version
@@ -31,15 +40,20 @@ module Buildr::Scala
       end
 
       def classifier
-        Buildr.settings.build['scala.check.classifier'] || ""
+        Buildr.settings.build['scala.check.classifier']
       end
 
       def artifact
-        Buildr.settings.build['scala.check.artifact'] || "scalacheck_#{Buildr::Scala.version}"
+        Buildr.settings.build['scala.check.artifact'] || "scalacheck_#{Buildr::Scala.version_without_build}"
       end
 
       def dependencies
-        (version =~ /:/) ? [version] : ["org.scala-tools.testing:#{artifact}:jar:#{classifier}:#{version}"]
+        return [version] if (version =~ /:/)
+        if classifier
+          ["org.scala-tools.testing:#{artifact}:jar:#{classifier}:#{version}"]
+        else
+          ["org.scala-tools.testing:#{artifact}:jar:#{version}"]
+        end
       end
 
     private
@@ -60,16 +74,26 @@ module Buildr::Scala
   # * :java_args   -- Arguments passed as is to the JVM.
   class ScalaTest < Buildr::TestFramework::Java
 
-    VERSION = '1.3'
+    VERSION = Buildr::Scala.version?(2.7, 2.8) ? '1.3' : '1.4.1'
 
     class << self
       def version
-        Buildr.settings.build['scala.test'] || VERSION
+        custom = Buildr.settings.build['scala.test']
+        (custom =~ /:/) ? Buildr.artifact(custom).version : VERSION
+      end
+
+      def specs
+        custom = Buildr.settings.build['scala.test']
+        return custom if (custom =~ /:/)
+        if Buildr::Scala.version?(2.7, 2.8)
+          "org.scalatest:scalatest:jar:#{version}"
+        else
+          "org.scalatest:scalatest_#{Buildr::Scala.version_without_build}:jar:#{version}"
+        end
       end
 
       def dependencies
-        ["org.scalatest:scalatest:jar:#{version}"] + Check.dependencies +
-          JMock.dependencies + JUnit.dependencies
+        [specs] + Check.dependencies + JMock.dependencies + JUnit.dependencies
       end
 
       def applies_to?(project) #:nodoc:

Modified: buildr/trunk/spec/sandbox.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/sandbox.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/sandbox.rb (original)
+++ buildr/trunk/spec/sandbox.rb Fri May 27 21:55:20 2011
@@ -21,8 +21,11 @@ Buildr.application.instance_eval { @rake
 repositories.remote << 'http://repo1.maven.org/maven2'
 repositories.remote << 'http://scala-tools.org/repo-releases'
 
-# Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
-Buildr.settings.build['scala.version'] = "2.8.1"
+# Force Scala version for specs; don't want to rely on SCALA_HOME
+module Buildr::Scala
+  SCALA_VERSION_FOR_SPECS = ENV["SCALA_VERSION"] || "2.8.1"
+end
+Buildr.settings.build['scala.version'] = Buildr::Scala::SCALA_VERSION_FOR_SPECS
 
 # Add a 'require' here only for optional extensions, not for extensions that should be loaded by default.
 require 'buildr/clojure'
@@ -48,6 +51,25 @@ end
 ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
 mkpath ENV['HOME']
 
+# Make Scala.version resilient to sandbox reset
+module Buildr::Scala
+  DEFAULT_VERSION = SCALA_VERSION_FOR_SPECS
+
+  class << self
+    def version
+      SCALA_VERSION_FOR_SPECS
+    end
+  end
+
+  class Scalac
+    class << self
+      def use_installed?
+        false
+      end
+    end
+  end
+end
+
 # We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
 # and restoring everything to its previous state after the test. Damn state changes.
 module Sandbox

Modified: buildr/trunk/spec/scala/bdd_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/bdd_spec.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/scala/bdd_spec.rb (original)
+++ buildr/trunk/spec/scala/bdd_spec.rb Fri May 27 21:55:20 2011
@@ -17,12 +17,7 @@
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
 
 describe Buildr::Scala::Specs do
-  
-  before(:each) do
-    # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
-    Buildr.settings.build['scala.version'] = "2.8.1"
-  end
-    
+
   it 'should be the default when tests in src/spec/scala' do
     write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
       package com.example

Modified: buildr/trunk/spec/scala/compiler_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/compiler_spec.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/scala/compiler_spec.rb (original)
+++ buildr/trunk/spec/scala/compiler_spec.rb Fri May 27 21:55:20 2011
@@ -19,11 +19,6 @@ require File.expand_path(File.join(File.
 # need to test both with and without SCALA_HOME
 share_as :ScalacCompiler do
 
-  before(:each) do
-    # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
-    Buildr.settings.build['scala.version'] = "2.8.1"
-  end
-
   it 'should identify itself from source directories' do
     write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
     define('foo').compile.compiler.should eql(:scalac)
@@ -143,15 +138,7 @@ describe 'scala compiler (downloaded fro
   end
 end
 
-
-describe 'scalac compiler options' do
-  def compile_task
-    @compile_task ||= define('foo').compile.using(:scalac)
-  end
-
-  def scalac_args
-    compile_task.instance_eval { @compiler }.send(:scalac_args)
-  end
+share_as :ScalacCompiler_CommonOptions do
 
   it 'should set warnings option to false by default' do
     compile_task.options.warnings.should be_false
@@ -200,16 +187,6 @@ describe 'scalac compiler options' do
     compile_task.options.debug.should be_false
   end
 
-  it 'should use -g argument when debug option is true' do
-    compile_task.using(:debug=>true)
-    scalac_args.should include('-g')
-  end
-
-  it 'should not use -g argument when debug option is false' do
-    compile_task.using(:debug=>false)
-    scalac_args.should_not include('-g')
-  end
-
   it 'should set deprecation option to false by default' do
     compile_task.options.deprecation.should be_false
   end
@@ -287,3 +264,58 @@ describe 'scalac compiler options' do
     ENV.delete "DEBUG"
   end
 end
+
+
+describe 'scala compiler 2.8 options' do
+
+  it_should_behave_like ScalacCompiler_CommonOptions
+
+  def compile_task
+    @compile_task ||= define('foo').compile.using(:scalac)
+  end
+
+  def scalac_args
+    compile_task.instance_eval { @compiler }.send(:scalac_args)
+  end
+
+  it 'should use -g argument when debug option is true' do
+    compile_task.using(:debug=>true)
+    scalac_args.should include('-g')
+  end
+
+  it 'should not use -g argument when debug option is false' do
+    compile_task.using(:debug=>false)
+    scalac_args.should_not include('-g')
+  end
+end if Buildr::Scala.version?(2.8)
+
+describe 'scala compiler 2.9 options' do
+
+  it_should_behave_like ScalacCompiler_CommonOptions
+
+  def compile_task
+    @compile_task ||= define('foo').compile.using(:scalac)
+  end
+
+  def scalac_args
+    compile_task.instance_eval { @compiler }.send(:scalac_args)
+  end
+
+  # these specs fail. Somehow the compiler is still in version 2.8
+  it 'should use -g:vars argument when debug option is true' do
+    compile_task.using(:debug=>true)
+    scalac_args.should include('-g:vars')
+  end
+
+  it 'should use -g:whatever argument when debug option is \'whatever\'' do
+    compile_task.using(:debug=>:whatever)
+    scalac_args.should include('-g:whatever')
+  end
+
+  it 'should not use -g argument when debug option is false' do
+    compile_task.using(:debug=>false)
+    scalac_args.should_not include('-g')
+  end
+
+end if Buildr::Scala.version?(2.9)
+

Modified: buildr/trunk/spec/scala/doc_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/doc_spec.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/scala/doc_spec.rb (original)
+++ buildr/trunk/spec/scala/doc_spec.rb Fri May 27 21:55:20 2011
@@ -18,11 +18,6 @@ require File.expand_path(File.join(File.
 
 describe "Scaladoc" do
 
-  before(:each) do
-    # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
-    Buildr.settings.build['scala.version'] = "2.8.1"
-  end
-
   it 'should pick -doc-title from project name by default' do
     define 'foo' do
       compile.using(:scalac)
@@ -52,7 +47,7 @@ describe "Scaladoc" do
     project('foo').doc.options[:"doc-title"].should eql('explicit')
   end
 
-  it 'should convert :windowtitle to -doc-title for Scala 2.8.1' do
+  it 'should convert :windowtitle to -doc-title for Scala 2.8.1 and later' do
     write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
     define('foo') do
       doc.using :windowtitle => "foo"
@@ -63,7 +58,7 @@ describe "Scaladoc" do
       0 # normal return
     end
     project('foo').doc.invoke
-  end
+  end unless Buildr::Scala.version?(2.7, "2.8.0")
 end
 
 describe "package(:scaladoc)" do

Modified: buildr/trunk/spec/scala/scala.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/scala.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/scala/scala.rb (original)
+++ buildr/trunk/spec/scala/scala.rb Fri May 27 21:55:20 2011
@@ -17,9 +17,6 @@
 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
 
 describe 'scala' do
-  # Specific version of Scala required for specs
-  required_version = '2.8.1'
-  scala_version_str = "2.8.1.final"
 
   it 'should automatically add the remote scala-tools.org repository' do
     # NOTE: the sandbox environment clears "repositories.remote" so we can't
@@ -28,11 +25,7 @@ describe 'scala' do
     # 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
-
   it "should provide the Scala version string" do
-    Scala.version_str.should eql(scala_version_str)
+    Scala.version_str.should eql(Buildr::Scala::SCALA_VERSION_FOR_SPECS)
   end
 end

Modified: buildr/trunk/spec/scala/tests_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/tests_spec.rb?rev=1128480&r1=1128479&r2=1128480&view=diff
==============================================================================
--- buildr/trunk/spec/scala/tests_spec.rb (original)
+++ buildr/trunk/spec/scala/tests_spec.rb Fri May 27 21:55:20 2011
@@ -22,15 +22,23 @@ require File.expand_path(File.join(File.
 #  -test exclude group
 #  -test include Suite's
 #  -test exclude Suite's
+#
+describe "scalatest version" do
 
+  case
+  when Buildr::Scala.version?(2.8)
+    it 'should be 1.3 for scala 2.8' do
+      Scala::ScalaTest.dependencies.should include("org.scalatest:scalatest:jar:1.3")
+    end
+  when Buildr::Scala.version?(2.9)
+    it 'should be 1.4.1 for scala 2.9' do
+      Scala::ScalaTest.dependencies.should include("org.scalatest:scalatest_2.9.0:jar:1.4.1")
+    end
+  end
+end
 
 describe Buildr::Scala::ScalaTest do
-  
-  before(:each) do
-    # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
-    Buildr.settings.build['scala.version'] = "2.8.1"
-  end
-    
+
   it 'should be the default test framework when test cases are in Scala' do
     write 'src/test/scala/com/example/MySuite.scala', <<-SCALA
       package com.example