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

Scala sbt在自定义sbt插件中获取真正的编译器选项,scala,sbt,Scala,Sbt,我知道sbt中有scalacOptions。但是,scalacOptions中不存在通过addCompilerPlugin添加的选项 我在sbt控制台中键入show scalacOptions,没有类似的-Xplugin 那么,在编写sbt插件时,如何获得realscalac选项呢 我的sbt信息 > libraryDependencies [info] List(org.scala-lang:scala-library:2.10.4, org.scala-lang:scala-refle

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

我在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
> 
我的身材.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)

你确定你已经添加了编译器插件吗

对于sbt 0.13.5和具有此in-build.sbt的空项目:

addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.10.1")
我在libraryDependencies和ScalaOptions中都获得了该插件:

> 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)

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

我很高兴看到我不是唯一一个在sbt上遇到麻烦的人。它只是没有文档,所以对项目进行git克隆,并尝试跟踪其中的源代码。/main/src/main/scala/sbt/Defaults.scalaI更新了我的问题,你能看一下吗。编译器插件实际运行了吗?您没有意外地将它添加到project/plugins.sbt而不是build.sbt吗?(编译器插件不是sbt插件)我在scala 2.10中使用quansiquote。而且它编译得很好,所以我猜插件添加成功了,我不知道。查看sbt源代码,addCompilerPlugin所做的唯一一件事就是用一个特殊的“配置”(“插件->默认值(编译)”)装饰ModuleID,然后将其添加到libraryDependencies,因此如果它能工作,它应该在那里。是的,正如您所说,library dependencies包含了这一点。