我正在使用带有 Sbt 0.13.2 的 xsbt-web-plugin。如果我将以下内容添加到 build.sbt 我可以在控制台中输入“myTask”并且它可以工作:
val myTask = taskKey[Unit]("My task.")
myTask := {
val (art, file) = packagedArtifact.in(Compile, packageWar).value
println("Artifact definition: " + art)
println("Packaged file: " + file.getAbsolutePath)
}
但是,如果我在 Sbt 控制台中键入它,为什么会返回错误?
inspect compile:packageWar::packagedArtifact
错误信息:
[error] Expected key
[error] Not a valid key: packageWar (similar: package, packageSrc, package-src)
[error] inspect compile:packageWar::packagedArtifact
[error] ^
为了比较,这个确实有效:
inspect compile:packageBin::packagedArtifact
build.sbt 的关键部分:
tomcat()
name := "my-war"
scalaVersion := "2.10.4"
webappSrc in webapp := baseDirectory.value / "web"
webInfClasses in webapp := true
val myTask = taskKey[Unit]("My task.")
myTask := {
val (art, file) = packagedArtifact.in(Compile, packageWar).value
println("Artifact definition: " + art)
println("Packaged file: " + file.getAbsolutePath)
}
项目/plugins.sbt:
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "1.0.0-M4")
(我只是问这样我可以更好地理解 Sbt,它实际上并没有引起问题。)