Module: Buildr::Kotlin

Defined in:
lib/buildr/kotlin/compiler.rb

Overview

The Kotlin Module

Defined Under Namespace

Modules: ProjectExtension Classes: Kotlinc, KotlincOptions

Constant Summary collapse

DEFAULT_VERSION =
'1.1.3-2'

Class Method Summary collapse

Class Method Details

.installed_versionObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/buildr/kotlin/compiler.rb', line 22

def installed_version
  unless @installed_version
    @installed_version = if Kotlinc.installed?
      begin
        # try to read the value from the build.txt file
        version_str = File.read(File.expand_path('build.txt', Kotlinc.kotlin_home))

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

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

  @installed_version
end

.versionObject



45
46
47
# File 'lib/buildr/kotlin/compiler.rb', line 45

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

.version?(*v) ⇒ Boolean

check if version matches any of the given prefixes

Returns:

  • (Boolean)


50
51
52
# File 'lib/buildr/kotlin/compiler.rb', line 50

def version?(*v)
  v.any? { |v| version.index(v.to_s) == 0 }
end