- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用新的 AutoPlugin 机制为 sbt 编写代码生成插件。我需要修改sourceGenerators in Compile
设置,但当我从插件中执行此操作时,它不起作用。调用compile后,屏幕上没有打印任何内容。
但是,如果我采取 sourceGenerators in Compile <+= (mySourceGenerator in Compile)
行并将其移至build.sbt
该项目突然sourceGenerators in Compile
设置被修改,当我运行编译任务时,消息被写入屏幕。
我有什么遗漏的吗?插件代码在这里:
package net.lopezbobeda.plugin
import sbt._
import Keys._
import java.io.{ File, Writer }
object MyPlugin extends AutoPlugin {
// by defining autoImport, the settings are automatically imported into user's `*.sbt`
object autoImport {
// configuration points, like the built-in `version`, `libraryDependencies`, or `compile`
lazy val mySourceGenerator = taskKey[Seq[File]]("Generate")
// default values for the tasks and settings
lazy val baseXtendPluginSettings: Seq[Def.Setting[_]] = Seq(
mySourceGenerator in Compile := {
val s: TaskStreams = streams.value
s.log.info("Generating! " + sourceManaged.value)
Nil
},
sourceGenerators in Compile <+= (mySourceGenerator in Compile) // if I put this line in build.sbt everything works as expected.
)
}
override def trigger = allRequirements
import autoImport._
override val projectSettings = baseXtendPluginSettings
}
最佳答案
问题是 JVM 插件重置了 sourceGenerators 设置。解决办法就是添加:
override def requires = JvmPlugin
我在另一个问题中找到了解决方案:
关于scala - 如何从 AutoPlugin 修改 Compile 中的 sourceGenerators?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25158287/
我正在使用 sourceGenerators in Compile生成一些 Scala 源文件到 target\scala-2.10\src_managed。当我跑 sbt compile源代码与 s
在我的 SBT 项目中,我有一个输入文件 src/main/greeting/Greeting.txt具有以下内容: Hello, world! 这是我的 build.sbt从 Greeting.tx
我正在使用新的 AutoPlugin 机制为 sbt 编写代码生成插件。我需要修改sourceGenerators in Compile设置,但当我从插件中执行此操作时,它不起作用。调用compile
我正在使用新的 AutoPlugin 机制为 sbt 编写代码生成插件。我需要修改sourceGenerators in Compile设置,但当我从插件中执行此操作时,它不起作用。调用compile
我是一名优秀的程序员,十分优秀!