My favorites | Sign in
Project Home Downloads Wiki Issues
Search
for

sbt has moved

sbt has now completely moved to GitHub.

See https://github.com/harrah/xsbt/wiki.

Getting Started

CompilerPlugins  
Updated Jul 27, 2011 by dmhar...@gmail.com

sbt has moved

sbt has now completely moved to GitHub.

See https://github.com/harrah/xsbt/wiki/Compiler-Plugins.

Compiler Plugin Support

There is some special support for using compiler plugins. You can mixin the AutoCompilerPlugins trait to your project definition to enable this functionality.

To use a compiler plugin, you either put it in your unmanaged library directory (lib) or add it as managed dependency in the plugin configuration. compilerPlugin is a convenience method for specifying plugin as the configuration for a dependency:

   val sxr = compilerPlugin("org.scala-tools.sxr" %% "sxr" % "0.2.6")

Alternatively, you can use inline Ivy XML:

   override def ivyXML =
      <dependencies>
         <dependency org="org.scala-tools.sxr" name="sxr" rev="0.2.6" conf="plugin->default(compile)"/>
      </dependencies>

A managed dependency is resolved and retrieved like usual by running update.

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:

  override def compileOptions =
    CompileOption("-Psxr:base-directory:" + mainScalaSourcePath.absolutePath) ::
    super.compileOptions.toList

You can still specify compiler plugins manually. For example:

  override def compileOptions = CompileOption("-Xplugin:<path-to-sxr>/sxr-0.2.6.jar") :: super.compileOptions.toList

Continuations Plugin Example

Support for continuations in Scala 2.8 is implemented as a compiler plugin. You can use AutoCompilerPlugins for this, as shown here.

import sbt._

class ContinuationsExample(info: ProjectInfo) extends DefaultProject(info) with AutoCompilerPlugins
{
  val cont = compilerPlugin("org.scala-lang.plugins" % "continuations" % "2.8.0")
  override def compileOptions = super.compileOptions ++ compileOptions("-P:continuations:enable")
}
Comment by 6b656e6a69@gmail.com, Sep 13, 2011

-Psxr:base-directory

-P:sxr:base-directory

?

:(

Powered by Google Project Hosting