scalaのsbtメモ
IntelliJでSparkのチュートリアルを動かそうとしたら、
うまくいかなかったので、まずはsbtという物を試す。
このHelloサンプルは動いた。
始める sbt — Hello, World
sbtを使って一番シンプルなscalaプログラムを動かすサンプル。
sbt-idea
sbt-ideaは、IntelliJのプロジェクトファイル(プロジェクトの設定ファイル?)を生成してくれるsbtコマンド。
http://d.hatena.ne.jp/Kazuhira/20110917/1316266356
cd INTELLIJ_PROJECTS/hello
sbt
compile
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.github.mpeltonen#sbt-idea;1.6.0: not found
[error] Total time: 19 s, completed Sep 4, 2015 4:54:43 PM
INTELLIJ_PROJECTS/hello/plugins.sbt
に
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
と書いてあるのでこのエラーになったっぽい。
動かない。↓で解決。
sbt-idea のための設定
https://github.com/mpeltonen/sbt-idea/issues/177
~/.sbt/0.13/plugins/build.sbt
に
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
を書いてsbtコマンド。
[info] Loading global plugins from /Users/kubotad/.sbt/0.13/plugins
[info] Updating {file:/Users/kubotad/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to hello (in build file:/Users/kubotad/IdeaProjects/hello/)
動いた。
IntelliJのプロジェクト設定ファイルを生成するコマンドは、
sbt gen-idea
最初は、
~/.sbt/plugins/build.sbt
に
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
を書いていて、sbtコマンドを実行したら、エラーだった。
[warn] The global sbt directory is now versioned and is located at /Users/kubotad/.sbt/0.13.
[warn] You are seeing this warning because there is global configuration in /Users/kubotad/.sbt but not in /Users/kubotad/.sbt/0.13.
[warn] The global sbt directory may be changed via the sbt.global.base system property.
[info] Set current project to hello (in build file:/Users/kubotad/IdeaProjects/hello/)