A simple-build-tool plugin/processor to create IntelliJ IDEA project files for sbt project
- Sbt version 0.7.×. NOTE: For SBT 0.10 version of the plugin, see branch sbt-0.10
- IntelliJ Idea version 9.0.3 (Scala plugin 0.3.2039). Not fully compatible with Scala plugin versions prior to
0.3.2039 because of changes in config xml format.
- Creates directory based IDEA project definition (.idea/) for sbt project.
- Creates IDEA module (.iml) for every sbt subproject. Supports multi-module projects.
- Creates IDEA module also for sbt project definition (optional, on by default).
- Can be used as sbt plugin or as sbt processor.
Tool can be used either as sbt plugin or sbt processor (thanks to teigen for the processor integration!).
Usage as plugin requires modification of your project descriptor, whereas usage as processor is non-intrusive and requires only few commands on the sbt console. Instructions for both usage scenarios below.
1. In your 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.4.0" }
2. In your project definition file:
import sbt._ class MyProject(info: ProjectInfo) extends DefaultProject(info) with IdeaProject { // ... }
If you have multi-module project, plugin trait must be mixed into subprojects too, for example:
import sbt._ class MyProject(info: ProjectInfo) extends ParentProject(info) with IdeaProject { lazy val mySubProject = project("my-subproject", "my-subproject", new DefaultProject(_) with IdeaProject) // ... }
3. Run
sbt update sbt idea
4. Open created project (sbt project’s root directory) in Idea
Check out sbt’s plugin documentation for further details.
1. Start sbt console on the root of your project
2. Enter the following sbt console commands (* is part of sbt processor command syntax):
> *sbtIdeaRepo at http://mpeltonen.github.com/maven/ > *idea is com.github.mpeltonen sbt-idea-processor 0.4.0 ... > update ... > idea ...
3. Open created project (sbt project’s root directory) in Idea
Check out sbt’s processor documentation for further details.
4. Upgrade to a new version
To upgrade to a new version of the plugin you need to remove the old version first
> *remove idea > *idea is com.github.mpeltonen sbt-idea-processor 0.4.0 ... > update ... > idea ...
You can customize some aspects of generated Idea project descriptors by creating a property file project/idea.properties
with desired properties. Currently supported properties are:
Property | Description | Default value |
---|---|---|
project.jdk.name | Value of the ‘project-jdk-name’ attribute of ProjectRootManager component | 1.6 |
project.output.path | If defined, use this (project relative) directory as output path for all modules, instead of sbt’s output path | no default |
java.language.level | Value of the ‘languageLevel’ attribute of ProjectRootManager component | JDK_1_6 |
include.sbt.project.definition.module | Generate Idea Module also for sbt project definition code | true |
excluded.folders | Comma separated list of folders in module root directory that will be marked as excluded, causing them to be invisible in IDEA’s project view | target |
compile.with.idea | If defined, sbt’s target resources and test-resources folders will not be added to classpath (since Idea copies them during compile) | false |
Starting from version 0.4.0, Workstation specific configuration can be defined in file $HOME/.sbt-idea. Supported properties are:
Property | Description | Default value |
---|---|---|
web.facet | Generate web facet for DefaultWebProject’s (Idea Community Edition does not support web facets). | true |
IDEA has an option of specifying a documentation URL for a dependency artifact. When documentation URL for a library containing given class is specified, pressing Shift+F1 when cursor is over a method or class will open default browser at the corresponding API doc page. You can specify this documentation url in sbt project definition by adding extra attribute called “docUrl” into dependency declaration. For example:
val jodaTime = "joda-time" % "joda-time" % "1.6.2" extra("docUrl" -> "http://joda-time.sourceforge.net/api-release/")
This currently works only for JavaDoc APIs, not ScalaDoc.
See contributors
Licensed under the New BSD License. See the LICENSE file for details.