0
我在兩個不同的環境(Windows XP和Linux)中運行Buildr,因此我在不同位置安裝了本地Java和Scala。我有以下做法來檢查環境變量設置:如何優雅地放棄Buildr?
require 'buildr/scala'
# Can I put these checks on a function ? How ?
ENV['JAVA_HOME'] ||= Buildr.settings.user['java_home']
if ENV['JAVA_HOME'].nil? then
puts "Required environment variable JAVA_HOME was not set. Value can also be set in personal settings."
Process.exit 1
end
puts 'JAVA_HOME = ' + ENV['JAVA_HOME']
ENV['SCALA_HOME'] ||= Buildr.settings.user['scala_home']
if ENV['SCALA_HOME'].nil? then
puts "Required environment variable SCALA_HOME was not set. Value can also be set in personal settings."
Process.exit 1
end
puts 'SCALA_HOME = ' + ENV['SCALA_HOME']
puts 'Scala version: ' + Scala.version
define "HelloWorld" do
puts 'Hello World !'
end
但是我怎麼退出Buildr,使之與這種消息的退出:
Buildr aborted!
RuntimeError : Scala compiler crashed:
#<NullPointerException: unknown exception>
(See full trace by running task with --trace)
我應該拋出一個異常(如果是的話,如何在Ruby中做到這一點)?
回答我的所有問題並向我介紹了其他有用的東西。我除了除非關鍵字(我更喜歡'如果不是'),所有這些都被使用了。謝謝 ! – user272735 2010-12-16 19:38:20