sbt不在编译时执行生成器

sbt不在编译时执行生成器,sbt,Sbt,我已将此添加到我的build.sbt中: resourceGenerators in Compile <+= (resourceManaged in Compile, name, version) map { (dir, n, v) => val file = dir / "version" val contents = Process("git rev-parse HEAD").lines.head IO.write(file, contents)

我已将此添加到我的build.sbt中:

resourceGenerators in Compile <+=
  (resourceManaged in Compile, name, version) map { (dir, n, v) =>
    val file = dir / "version"
    val contents = Process("git rev-parse HEAD").lines.head
    IO.write(file, contents)
    println("I have just been run")
    Seq(file)
  }

生成的源任务的可能重复项不是专门在
run
上运行,而是在
compile
上运行<代码>运行依赖于
编译
,如果没有进一步的工作,sbt将不知道生成的源代码被缓存在某个地方,因此它假设每次都需要重新编译该源代码。有关缓存生成的源的解决方案,请参阅链接问题。谢谢。但我的问题不同。它根本不会在编译时运行!当调用“run”时,资源只出现在目标路径上,这很尴尬,但我三次验证了这不是一个重复的人。因此,您的意思是,如果在上面的
val文件
之前添加
println(“HELLO”)
,则在运行
sbt compile
时,您不会看到该文本?听起来很奇怪。
[info] This is sbt 0.13.5
[info] The current project is built against Scala 2.11.2
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, play.twirl.sbt.SbtTwirl, com.scalapenos.sbt.prompt.SbtPrompt, com.typesafe.sbteclipse.plugin.EclipsePlugin, com.typesafe.sbt.SbtStartScript, spray.revolver.RevolverPlugin, org.netbeans.nbsbt.plugin.NetBeansPlugin, com.typesafe.sbt.SbtScalariform, sbtbuildinfo.Plugin, com.typesafe.sbt.SbtGit
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4