注释处理器输出路径sbt?

注释处理器输出路径sbt?,sbt,Sbt,有没有办法在sbt中设置注释处理器输出路径 目前,它将文件生成为: target/scala-2.11/classes 不过我更愿意 target/scala-2.11/src\u管理的类似 // in build.sbt: // create managed source directory before compile compile in Compile <<= (compile in Compile) dependsOn Def.task { (managedSourceD

有没有办法在sbt中设置注释处理器输出路径

目前,它将文件生成为:

target/scala-2.11/classes

不过我更愿意

target/scala-2.11/src\u管理的

类似

// 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),
//在build.sbt中:
//编译前创建托管源目录

在sbt
0.13.15中编译

compile:=((在编译中编译)dependsOn Def.task{
(sourceManaged in Compile).value.mkdirs()
}).价值,
Compile++=Seq(“-s”,s“${sourceManaged.value}/main”)中的javacopions

配置
sourceManaged
而不是
managedSourceDirectories
更符合人体工程学

添加到
build.sbt
中的sbt模块设置:

Compile / javacOptions ++= Seq("-s", (Compile / sourceManaged).value.getAbsolutePath)
您还可以将此插件放入
项目
文件夹中

package custom.sbt
导入sbt.{Def,}
导入sbt.Keys_
对象编译器扩展了AutoPlugin{
覆盖def触发器=所有要求
覆盖def buildSettings:Seq[定义设置[]]=Seq(
Compile/javacopions++=Seq(“-source”,“11”,“-target”,“11”),
scalacOptions++=Seq(
“-目标:11”//target JRE 11
)
)
覆盖def项目设置:Seq[定义设置[]]=Seq(
Compile/javacOptions++=Seq(“-s”,(Compile/sourceManaged).value.getAbsolutePath)
)
}

See and similar这根本没有帮助。我不得不在Compile++=Seq(“-s”)(Compile中的managedSourceDirectories.value.head.getAbsolutePath)中将其更改为
javacopions,但随后它就工作了。谢谢你的评论!谢谢,我只是忽略了你的答案complete.btw,实际上这是可行的,但是在一个“更干净”的环境中(例如jenkins),我们得到了以下信息:``java.lang.IllegalStateException:directory not found:(已发出)/target/scala-2.11/src_managed/main``有什么办法解决这个问题吗?首先创建目录,例如,
compile,实际上这会给我一个错误:
引用未定义的设置::::compile from*:compile