sbt在自定义sbt插件中获取真正的编译器选项

时间:2014-07-03 03:06:39

标签: scala sbt

我知道sbt中有scalacOptions。但addCompilerPlugin中不存在通过scalacOptions添加的选项。

我在sbt控制台中输入show scalacOptions,没有像-Xplugin那样的内容。

那么在编写sbt插件时如何获得real scalac选项

我的sbt信息

> libraryDependencies
[info] List(org.scala-lang:scala-library:2.10.4, org.scala-lang:scala-reflect:2.10.4, io.netty:netty:3.9.0.Final, net.sandrogrzicic:scalabuff-runtime:1.3.7, org.scalamacros:quasiquotes:2.0.0, org.specs2:specs2:2.3.11:test, org.scalamacros:paradise:2.0.0:plugin->default(compile))
> show scalacOptions
[info] List(-feature, -deprecation, -language:implicitConversions, -language:dynamics)
[success] Total time: 0 s, completed Jul 3, 2014 4:04:09 PM
> version
[info] 0.0.1-SNAPSHOT
> sbt
sbtBinaryVersion    sbtClearOnFailure   sbtDependency       sbtPlugin           sbtPopOnFailure     sbtResolver         sbtStashOnFailure   
> sbtVersion
[info] 0.13.5
> 

我的build.sbt

libraryDependencies ++= Seq(
  "org.scala-lang" % "scala-reflect" % "2.10.4",
  "io.netty" % "netty" % "3.9.0.Final",
  "net.sandrogrzicic" %% "scalabuff-runtime" % "1.3.7",
  "org.scalamacros" %% "quasiquotes" % "2.0.0",
  "org.specs2" %% "specs2" % "2.3.11" % "test")

scalacOptions ++= Seq(
  "-feature",
  "-deprecation",
  "-language:implicitConversions",
  "-language:dynamics"
)

parallelExecution in Test := false

addCompilerPlugin("org.scalamacros" % "paradise" % "2.0.0" cross CrossVersion.full)

2 个答案:

答案 0 :(得分:1)

最后我发现compile:scalacOptions实际上包含了插件设置

答案 1 :(得分:0)

你确定你真的设法添加了编译器插件吗?

使用sbt 0.13.5和build.sbt中的空项目:

addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.1")

我在libraryDependencies和scalacOptions中都获得了插件:

> libraryDependencies
[info] List(org.scala-lang:scala-library:2.10.4, org.scala-lang.plugins:continuations:2.10.1:plugin->default(compile))
> show scalacOptions
[info] List(-Xplugin:/Users/johan/.ivy2/cache/org.scala-lang.plugins/continuations/jars/continuations-2.10.1.jar)