如何将 sbt 0.12 "<<= map case" 转换为 sbt 1.x
How to convert sbt 0.12 "<<= map case" to sbt 1.x
sbt 0.12 build.sbt
val myTask = TaskKey[Unit]("mytask")
lazy val baseSettings = Seq(
javacOptions ++= Seq("-g", "-encoding", "utf8")
)
lazy val appSettings = baseSettings ++ Seq(
myTask <<= (fullClasspath in Runtime, normalizedName, target, packageOptions, streams, cacheDirectory) map {
case (fullClasspath: Classpath, normalizedName: String, target: File, packageOptions: Seq[PackageOption], streams: TaskStreams, cacheDirectory: File) => {
streams.log.info("my task appSettings")
}
}
)
想将以下代码更新为sbt 1.x
myTask <<= (fullClasspath in Runtime, normalizedName, target, packageOptions, streams, cacheDirectory) map {
case (fullClasspath: Classpath, normalizedName: String, target: File, packageOptions: Seq[PackageOption], streams: TaskStreams, cacheDirectory: File) => {
谢谢
Update:
I find some information at scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html, but I don't know how to use ":=" with "case"
EDIT:
Mateusz Kubuszok is right, not need "case", and "cacheDirectory" can be replaced by "streams.value.cacheDirectory"
而不是 <<=
你使用 :=
.
而不是设置元组和 map
,您只需在 key/settings 上调用 .value
。
cacheDirectory
已删除。
从 1.1 开始还有 unified path syntax
lazy val appSettings = Seq(
myTask := {
streams.value.log.info(s"my task appSettings: ${(Runtime / fullClasspath).value}, ${normalizedName.value}, ${target.value}, ${packageOptions.value}")
}
)
在更复杂的任务中,您可能需要查阅有关例如order of execution.
sbt 0.12 build.sbt
val myTask = TaskKey[Unit]("mytask")
lazy val baseSettings = Seq(
javacOptions ++= Seq("-g", "-encoding", "utf8")
)
lazy val appSettings = baseSettings ++ Seq(
myTask <<= (fullClasspath in Runtime, normalizedName, target, packageOptions, streams, cacheDirectory) map {
case (fullClasspath: Classpath, normalizedName: String, target: File, packageOptions: Seq[PackageOption], streams: TaskStreams, cacheDirectory: File) => {
streams.log.info("my task appSettings")
}
}
)
想将以下代码更新为sbt 1.x
myTask <<= (fullClasspath in Runtime, normalizedName, target, packageOptions, streams, cacheDirectory) map {
case (fullClasspath: Classpath, normalizedName: String, target: File, packageOptions: Seq[PackageOption], streams: TaskStreams, cacheDirectory: File) => {
谢谢
Update:
I find some information at scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html, but I don't know how to use ":=" with "case"
EDIT:
Mateusz Kubuszok is right, not need "case", and "cacheDirectory" can be replaced by "streams.value.cacheDirectory"
而不是 <<=
你使用 :=
.
而不是设置元组和 map
,您只需在 key/settings 上调用 .value
。
cacheDirectory
已删除。
从 1.1 开始还有 unified path syntax
lazy val appSettings = Seq(
myTask := {
streams.value.log.info(s"my task appSettings: ${(Runtime / fullClasspath).value}, ${normalizedName.value}, ${target.value}, ${packageOptions.value}")
}
)
在更复杂的任务中,您可能需要查阅有关例如order of execution.