61 lines
1.8 KiB
Ruby
61 lines
1.8 KiB
Ruby
require 'formula'
|
|
|
|
class Scala < Formula
|
|
homepage 'http://www.scala-lang.org/'
|
|
url 'http://www.scala-lang.org/files/archive/scala-2.11.1.tgz'
|
|
sha1 '058281d9ed7738c99a9d5cd4988370448a12d0c1'
|
|
|
|
option 'with-docs', 'Also install library documentation'
|
|
option 'with-src', 'Also install sources for IDE support'
|
|
|
|
resource 'docs' do
|
|
url 'http://www.scala-lang.org/files/archive/scala-docs-2.11.1.zip'
|
|
sha1 'd2dfe19d04f42932aaf6fcb5d3025c16a7c8a0cb'
|
|
end
|
|
|
|
resource 'src' do
|
|
url 'https://github.com/scala/scala/archive/v2.11.1.tar.gz'
|
|
sha1 '934a2a5e158324399d24f81c9014032ffa0e91ff'
|
|
end
|
|
|
|
resource 'completion' do
|
|
url 'https://raw.githubusercontent.com/scala/scala-dist/27bc0c25145a83691e3678c7dda602e765e13413/completion.d/2.9.1/scala'
|
|
sha1 'e2fd99fe31a9fb687a2deaf049265c605692c997'
|
|
end
|
|
|
|
def install
|
|
rm_f Dir["bin/*.bat"]
|
|
doc.install Dir['doc/*']
|
|
share.install "man"
|
|
libexec.install "bin", "lib"
|
|
bin.install_symlink Dir["#{libexec}/bin/*"]
|
|
bash_completion.install resource('completion')
|
|
doc.install resource('docs') if build.with? 'docs'
|
|
libexec.install resource('src').files('src') if build.with? 'src'
|
|
|
|
# Set up an IntelliJ compatible symlink farm in 'idea'
|
|
idea = prefix/'idea'
|
|
idea.install_symlink libexec/'src', libexec/'lib'
|
|
(idea/'doc/scala-devel-docs').install_symlink doc => 'api'
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
To use with IntelliJ, set the Scala home to:
|
|
#{opt_prefix}/idea
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
file = testpath/'hello.scala'
|
|
file.write <<-EOS.undent
|
|
object Computer {
|
|
def main(args: Array[String]) {
|
|
println(2 + 2)
|
|
}
|
|
}
|
|
EOS
|
|
output = `'#{bin}/scala' #{file}`
|
|
assert_equal "4", output.strip
|
|
assert $?.success?
|
|
end
|
|
end
|