-
Notifications
You must be signed in to change notification settings - Fork 1
Compiler Plugins
The documentation for sbt has moved to http://scala-sbt.org. The new location for this page is http://scala-sbt.org/release/docs/Detailed-Topics/Compiler-Plugins.
There is some special support for using compiler plugins. You can set auto-compiler-plugins
to true
to enable this functionality.
autoCompilerPlugins := true
To use a compiler plugin, you either put it in your unmanaged library directory (lib/
by default) or add it as managed dependency in the plugin
configuration. addCompilerPlugin
is a convenience method for specifying plugin
as the configuration for a dependency:
addCompilerPlugin("org.scala-tools.sxr" %% "sxr" % "0.2.7")
The compile
and test-compile
actions will use any compiler plugins found in the lib
directory or in the plugin
configuration. You are responsible for configuring the plugins as necessary. For example, Scala X-Ray requires the extra option:
// declare the main Scala source directory as the base directory
scalacOptions <<= (scalacOptions, scalaSource in Compile) { (options, base) =>
options :+ ("-Psxr:base-directory:" + base.getAbsolutePath)
}
You can still specify compiler plugins manually. For example:
scalacOptions += "-Xplugin:<path-to-sxr>/sxr-0.2.7.jar"
Support for continuations in Scala 2.8 is implemented as a compiler plugin. You can use the compiler plugin support for this, as shown here.
autoCompilerPlugins := true
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.8.1")
scalacOptions += "-P:continuations:enable"
Adding a version-specific compiler plugin can be done as follows:
autoCompilerPlugins := true
libraryDependencies <<= (scalaVersion, libraryDependencies) { (ver, deps) =>
deps :+ compilerPlugin("org.scala-lang.plugins" % "continuations" % ver)
}
scalacOptions += "-P:continuations:enable"
- Home - Overview of sbt
- Getting Started Guide - START HERE
- FAQ - Questions, answered.
- Index - Find types, values, and methods
- Community - source, forums, releases
- Examples
-
Detailed Topics - deep dive docs
- Artifacts what to publish
- Best Practices
- Classpaths
- Command Line Reference
- Compiler Plugins
- Console Project
- Cross Build
- Forking
- Global Settings
- Inspecting Settings
- Java Sources
- Launcher
- Library Management
- Local Scala
- Mapping Files
- Migrating to 0.10+
- Parallel Execution
- Parsing Input
- Paths
- Process
- Publishing
- Resolvers
- Running Project Code
- Scripts
- Setup Notes
- Tasks
- TaskInputs
- Testing
- Triggered Execution
- Update Report
- Extending sbt - internals docs