Scala 覆盖自定义SBT任务的fork设置
我正在SBT中实现一个自定义任务,它运行一些外部Java类。我正在使用Scala 覆盖自定义SBT任务的fork设置,scala,sbt,Scala,Sbt,我正在SBT中实现一个自定义任务,它运行一些外部Java类。我正在使用runner任务来完成它 myCustomTask := { val mainClass: String = ??? val classpath: Seq[File] = ??? val options: Seq[String] = ??? runner.value.run(mainClass, classpath, options, streams.value.log) } 我想配置此任务,使其在单独的JV
runner
任务来完成它
myCustomTask := {
val mainClass: String = ???
val classpath: Seq[File] = ???
val options: Seq[String] = ???
runner.value.run(mainClass, classpath, options, streams.value.log)
}
我想配置此任务,使其在单独的JVM中运行。通常,这是使用fork
选项配置的,然后由runner
任务引用该选项
我只想为我的自定义任务配置fork。我试着这样做:
fork in myCustomTask := true
但它不起作用。runner
任务仍然获得未更改的fork
值
我还尝试通过使用(myCustomTask中的runner)
来调整任务本身,而不仅仅是runner
,但这也没有帮助
如何将
fork
设置为true
仅用于myCustomTask
?使用fullRunTask
,如所述使用fullRunTask
,我最终解决了以下问题:
fork in myCustomTask := true,
myCustomTask := {
val mainClass: String = ???
val classpath: Seq[File] = ???
val options: Seq[String] = ???
val runner = initScoped(myCustomTask.scopedKey, Defaults.runnerInit).value
runner.run(mainClass, classpath, options, streams.value.log)
}
我最终决定这样做:
fork in myCustomTask := true,
myCustomTask := {
val mainClass: String = ???
val classpath: Seq[File] = ???
val options: Seq[String] = ???
val runner = initScoped(myCustomTask.scopedKey, Defaults.runnerInit).value
runner.run(mainClass, classpath, options, streams.value.log)
}
这很好,但我不喜欢它只适用于返回
Unit
的任务。它实际上不允许您配置ForkOptions。这很好,但我不喜欢它只适用于返回Unit
的任务。它不允许您配置ForkOptions。