Module: Buildr::Scala

Defined in:
lib/buildr/scala/bdd.rb,
lib/buildr/scala/shell.rb,
lib/buildr/scala/tests.rb,
lib/buildr/scala/compiler.rb

Defined Under Namespace

Modules: Check Classes: ScalaShell, ScalaTest, Scalac, Specs

Constant Summary collapse

DEFAULT_VERSION =
'2.8.1'

Class Method Summary collapse

Class Method Details

.compatible_28?Boolean

Returns:

  • (Boolean)


62
63
64
65
66
67
68
69
# File 'lib/buildr/scala/compiler.rb', line 62

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
end

.installed_versionObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/buildr/scala/compiler.rb', line 31

def installed_version
  unless @installed_version
    @installed_version = if Scalac.installed?
      begin
        # 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

        version_str = props.match(/version\.number\s*=\s*([^\s]+)/).to_a[1]

        if version_str
          md = version_str.match(/\d+\.\d[\d\.]*/) or
            fail "Unable to parse Scala version: #{version_str}"

          md[0].sub(/.$/, "") # remove trailing dot, if any
        end
      rescue => e
        warn "Unable to parse library.properties in $SCALA_HOME/lib/scala-library.jar: #{e}"
        nil
      end
    end
  end

  @installed_version
end

.versionObject



58
59
60
# File 'lib/buildr/scala/compiler.rb', line 58

def version
  Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION
end

.version_strObject



26
27
28
29
# File 'lib/buildr/scala/compiler.rb', line 26

def version_str
  warn "Use of Scala.version_str is deprecated.  Use Scala.version instead"
  version
end