有没有办法在sbt中设置注释处理器输出路径?
目前它将文件生成为:
target/scala-2.11/classes
但我更喜欢
target/scala-2.11/src_managed
答案 0 :(得分:3)
像
这样的东西// in build.sbt:
// create managed source directory before compile
compile in Compile <<= (compile in Compile) dependsOn Def.task { (managedSourceDirectories in Compile).value.head.mkdirs() },
// tell the java compiler to output generated source files to the managed source directory
javacOptions in Compile ++= Seq("-s", (managedSourceDirectories in Compile).value.head.getAbsolutePath),
答案 1 :(得分:0)
在sbt 0.13.15
compile := ((compile in Compile) dependsOn Def.task {
(sourceManaged in Compile).value.mkdirs()
}).value,
javacOptions in Compile ++= Seq("-s", s"${sourceManaged.value}/main")
答案 2 :(得分:0)
配置sourceManaged
而不是managedSourceDirectories
更加符合人体工程学。
在build.sbt
中添加到sbt模块的设置:
Compile / javacOptions ++= Seq("-s", (Compile / sourceManaged).value.getAbsolutePath)
您也可以将此插件拖放到project
文件夹中
package custom.sbt
import sbt.{Def, _}
import sbt.Keys._
object Compiler extends AutoPlugin {
override def trigger = allRequirements
override def buildSettings: Seq[Def.Setting[_]] = Seq(
Compile / javacOptions ++= Seq("-source", "11", "-target", "11"),
scalacOptions ++= Seq(
"-target:11" // Target JRE 11
)
)
override def projectSettings: Seq[Def.Setting[_]] = Seq(
Compile / javacOptions ++= Seq("-s", (Compile / sourceManaged).value.getAbsolutePath)
)
}