sbt-idea (plugin and processor)
sbtのよさげなプラグインがリリースされてたので使ってみる。
http://implicit.ly/sbt-idea-010
sbtのプロジェクト定義からIDEAのプロジェクトとかモジュールを生成してくれるんですって。わーい。
sbtプロジェクト作成
ここはいつも通りですね。Scala2.8.1.final出たので2.8.1使いましょう。
$ sbt Project does not exist, create new project? (y/N/s) y Name: MyProject Organization: example Version [1.0]: Scala version [2.7.7]: 2.8.1 sbt version [0.7.4]: ... [info] Building project MyProject 1.0 against Scala 2.8.1 [info] using sbt.DefaultProject with sbt 0.7.4 and Scala 2.7.7
Plugins.scala
プロジェクトフォルダの project/plugins/Plugins.scala を編集(作成)します。
import sbt._ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { val sbtIdeaRepo = "sbt-idea-repo" at "http://mpeltonen.github.com/maven/" val sbtIdea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1.0" }
Project.scala
project/build/Project.scala も編集。
import sbt._ class MyProject(info: ProjectInfo) extends DefaultProject(info) with IdeaProject { // ... }
IdeaProjectをミックスインします。
マルチモジュールなプロジェクトを作成したい場合、すべてのサブプロジェクトにIdeaProjectをミックスインする必要があります。
idea.properties
project/idea.propertiesを編集すると、作成されるIDEAプロジェクトの設定を調整できます。
デフォルトで問題ないと思いますが、IDEAに名前変えてjdk設定してるのでそこだけ変更。(デフォルトだと1.6)
project.jdk.name=1.6.0_22
他にもjava.language.level(デフォルトJDK_1_6)やらproject.output.pathやらあります。
sbt update
sbt updateを実行します。
$ sbt update [info] Recompiling plugin definition... [info] Source analysis: 1 new/modified, 0 indirectly invalidated, 0 removed. ... [success] Build completed successfully.
pluginをDLしてきます。
sbt idea
sbt idea実行。
$ sbt idea [info] Building project MyProject 1.0 against Scala 2.8.1 [info] using MyProject with sbt 0.7.4 and Scala 2.7.7 [info] [info] == idea == [info] Created D:\Project\MyProject\.idea [info] Created D:\Project\MyProject/project/sbt_project_definition.iml [info] Created D:\Project\MyProject/MyProject.iml [info] == idea == [success] Successful. ...
おー、IDEAのプロジェクトファイルが作成されました。