- CentOS 6.3
- Oracle Java JDK 1.6
- Scala 2.10.1
- SBT 0.12
- IntelliJ IDEA Community 12.0.4
Add the SBT and Scala language plug-ins:
- Click Configure:
- Click Plugins:
- Click Browse repositories:
- Click the search box and enter “scala”:
- Select both SBT and Scala Language plugins by shift-left clicking on them
- Right click on one of the plugins and select Download and Install
- Click Install then Close then Ok and restart IntelliJ IDEA
Try out SBT Console
- After IntelliJ IDEA restarts, either load an existing Scala project or create an empty Scala project
- Click on SBT console in lower left corner:
- Click on the play icon:
- IntelliJ will download SBT and Scala jars then display the SBT command-line:
Configure SBT gen-idea command for the current user
- Make directories if missing:
- Add the SBT plugin for generating IntelliJ IDEA project files, edit ~/.sbt/plugins/build.sbt:
Default123resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.2.0-SNAPSHOT")
- Load ~/.sbt/plugins/build.sbt, by entering reload in the SBT console:
Default1234567> reload[info] downloading http://oss.sonatype.org/content/repositories/snapshots/com/github/mpeltonen/sbt-idea_2.9.2_0.12/1.2.0-SNAPSHOT/sbt-idea-1.2.0-SNAPSHOT.jar ...[info] [SUCCESSFUL ] com.github.mpeltonen#sbt-idea;1.2.0-SNAPSHOT!sbt-idea.jar (1309ms)[info] downloading http://repo1.maven.org/maven2/commons-io/commons-io/2.0.1/commons-io-2.0.1.jar ...[info] [SUCCESSFUL ] commons-io#commons-io;2.0.1!commons-io.jar (184ms)[info] Done updating.[info] Set current project to scala.statemachine (in build file:/home/XXXXXX/Code/smach/)
- Use any existing build.sbt or create a blank build.sbt (see SBT: Standard build.sbt for Scala) then invoke at SBT console:
- After downloads complete and generation is complete, click Ok and IntelliJ will restart
the SBT plugin will automatically download the appropriate Scala compiler version. This is a separate instance from any instance of the Scala compiler you may have installed already.
Thanks for the nice ‘get started’ series, very simple to follow and perfect for getting started on these very interesting technologies.
I have a question about item 16 on this page, where you write:
Use any existing build.sbt or create a blank build.sbt then invoke at sbt console:
I don’t know my way around SBT, so this probably will more make sense in the coming weeks.. But what exactly is going on in this step..?
Thanks for your feedback. I added a link to a standard build.sbt that can be used on step 16.
Sbt uses a build file named ‘build.sbt’ to get the options necessary to build your project. Once you have the IntelliJ IDEA sbt plugin configured and have a build.sbt created, the sbt command ‘gen-idea’ will cause sbt to generate all of the project files for IntelliJ IDEA. After that you can open the project in IntelliJ IDEA.
Awesome. Thanks a lot Lance, up and running now.
How do I make Idea use “sbt compile” instead of its own built-in compiler which can be called by Ctrl+F9 or Build -> Make Project? Of course, I can say “compiler” in sbt console, but I would like do that by pressing Ctrl+F9 or by pressing Make Project icon.
Hi Alex! I don’t know the answer to this one. I never use IntelliJ’s built in compiler. I always use the sbt console.