module Object::Scala

The Scala Module

Constants

DEFAULT_VERSION

Public Class Methods

installed_version() click to toggle source
# File lib/buildr/scala/compiler.rb, line 27
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
version() click to toggle source
# File lib/buildr/scala/compiler.rb, line 54
def version
  Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION
end
version?(*v) click to toggle source

check if version matches any of the given prefixes

# File lib/buildr/scala/compiler.rb, line 59
def version?(*v)
  v.any? { |v| version.index(v.to_s) == 0 }
end
version_str() click to toggle source
# File lib/buildr/scala/compiler.rb, line 22
def version_str
  warn "Use of Scala.version_str is deprecated.  Use Scala.version instead"
  version
end
version_without_build() click to toggle source

returns Scala version without build number. e.g. “2.9.0-1” => “2.9.0”

# File lib/buildr/scala/compiler.rb, line 65
def version_without_build
  version.split('-')[0]
end