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
Overview
The Scala Module
Defined Under Namespace
Modules: Check, Mockito, ProjectExtension Classes: ScalaShell, ScalaTest, Scalac, ScalacOptions, Specs2
Constant Summary collapse
- DEFAULT_VERSION =
'2.11.8'
Class Method Summary collapse
- .installed_version ⇒ Object
- .version ⇒ Object
-
.version?(*v) ⇒ Boolean
check if version matches any of the given prefixes.
-
.version_major_minor ⇒ Object
returns Scala version without tiny number.
- .version_str ⇒ Object
-
.version_without_build ⇒ Object
returns Scala version without build number.
Class Method Details
.installed_version ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# 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::File.open(File.('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 ⇒ Object
54 55 56 |
# File 'lib/buildr/scala/compiler.rb', line 54 def version Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION end |
.version?(*v) ⇒ Boolean
check if version matches any of the given prefixes
59 60 61 |
# File 'lib/buildr/scala/compiler.rb', line 59 def version?(*v) v.any? { |v| version.index(v.to_s) == 0 } end |
.version_major_minor ⇒ Object
returns Scala version without tiny number. e.g. “2.11.8” => “2.11”
71 72 73 |
# File 'lib/buildr/scala/compiler.rb', line 71 def version_major_minor version.split('.')[0..1].join('.') end |