开发者

sbt: can i put the source of scala compiler plugin into a project that needs to be compiled using that plugin?

i'm writing my own scala compiler plugin and using sbt to build the project. is it possible to put the source of that plugin in the same proj开发者_Python百科ect that needs to be compiled using that plugin?

all the documentation on sbt seems to be concerned with using a plugin that's external to the project. it just seems much easier to test the plugin if they're in the same project. otherwise i have to continuously build the plugin, copy that jar over to the main project, and then compile that.

the documentation i read is at http://code.google.com/p/simple-build-tool/wiki/CompilerPlugins.


Here is an example using SBT 0.13:

 object PluginBuild extends Build {

  def buildSettings = Seq(
    name := "test-compiler-plugin",
    scalaVersion := "2.10.3"
  )

  override def settings = super.settings ++ buildSettings

  lazy val codeToBeChecked = project.in(file("code-to-be-checked")).
    settings(
      scalacOptions += "-Xplugin:" + packageBin.in(Compile).in(thePlugin).value
    )

  lazy val thePlugin = project.in(file("the-plugin")).settings(
    libraryDependencies += "org.scala-lang" % "scala-compiler"  % scalaVersion.value
  )
}


I am not shure about what you are doing, but maybe is the project/plugins/src_managed/ diriectory what you are looking for. If the user of the plugin needs some code from the plugin, it can be found there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜