class Transcriptic::SBT

Public Class Methods

clean() click to toggle source
# File lib/transcriptic/sbt.rb, line 32
def clean
  ensure_installed
  sbt("clean")
end
compile() click to toggle source
# File lib/transcriptic/sbt.rb, line 6
def compile
  ensure_installed
  sbt("package")
end
stage() click to toggle source
# File lib/transcriptic/sbt.rb, line 11
def stage
  ensure_installed
  if sbt("package")
    jars = Dir.glob("target/scala-2.10/*.jar")
    if jars.length == 0
      output_with_arrow "Couldn't find compiled package!  Is your code in the right directory?"
      false
    elsif jars.length > 1
      output_with_arrow "Multiple packages found: I'm unsure which one is correct.  Try `transcriptic clean` and recompiling."
      false
    else
      jars[0]
    end
  end
end
update() click to toggle source
# File lib/transcriptic/sbt.rb, line 27
def update
  ensure_installed
  sbt("update")
end

Private Class Methods

ensure_installed() click to toggle source
# File lib/transcriptic/sbt.rb, line 38
def ensure_installed
  stat = `which sbt`
  if stat.empty?
    output_with_arrow "Downloading sbt..."
    Transcriptic::SBT::Installer.new(["/usr/local"], {}).invoke_all
  end
end
sbt(action) click to toggle source
# File lib/transcriptic/sbt.rb, line 46
def sbt(action)
  base = Transcriptic.find_labfile.dirname
  output_with_arrow "Detected Scala sources in app..."
  output_with_arrow "Compiling..."
  display

  code = IO.popen("sbt #{action}") do |stream|
    stream.each do |line|
      output_with_indent line
    end
  end

  display

  if 0 == $?
    output_with_arrow "Compilation succeeded."
    true
  else
    output_with_arrow "Errors occurred!"
    false
  end
end