0

scalac <some file>andrun <some class>ループで JVM の起動とクリーンアップが遅くなるのを避けたかっただけです。つまり、一度ロードしてからアプリを複数回コンパイルして実行できる環境を求めました。#scala チャンネルで、 の使用を勧められましたsbt

#progfun コースで既製の sbt スクリプトを使用したことがありますが、自分で sbt をプログラムしたことはありません。それは地獄のように見えます。私のタスクに合わせてどのように簡単に構成できますか?

4

1 に答える 1

1
% mkdir myproj 
% cd myproj 
% echo 'object MyProject extends App { println("hello world") }' > MyProject.scala
% sbt
[info] Loading global plugins from /Users/tisue/.sbt/0.13/plugins
[info] Set current project to myproj (in build file:/Users/tisue/myproj/)
> set scalaVersion := "2.11.7"
[info] Defining *:scalaVersion
[info] The new value will be used by *:Additional arguments for the presentation compiler., *:allDependencies and 13 others.
[info]  Run `last` for details.
[info] Reapplying settings...
[info] Set current project to myproj (in build file:/Users/tisue/myproj/)
> session save
[info] Reapplying settings...
[info] Set current project to myproj (in build file:/Users/tisue/myproj/)
> run
[info] Updating {file:/Users/tisue/myproj/}myproj...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/tisue/myproj/target/scala-2.11/classes...
[info] Running MyProject 
hello world
[success] Total time: 2 s, completed Nov 18, 2015 9:46:26 PM
> 

src/main/scala必要に応じて、ソースをプロジェクト ディレクトリのルート レベルではなく、その下に置くことができます。これも機能します。

session savebuild.sbt次のようなファイルを作成します。

scalaVersion := "2.11.7"

set必要に応じて、とを使用するかsession save、ファイルを直接編集して、後で設定を追加できます。

明示的に設定しないscalaVersionと、残念ながら 2.11 ではなく Scala 2.10 になってしまいます :-(

于 2015-11-19T02:48:34.587 に答える