1

我正在使用带有 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,它实际上并没有引起问题。)

4

1 回答 1

2

package您可以从而不是从以下位置获取此信息packageWar

> inspect compile:package::packagedArtifact
[info] Task: scala.Tuple2[sbt.Artifact, java.io.File]
[info] Description:
[info]  Generates a packaged artifact, returning the Artifact and the produced File.

packageWar任务是使用间接设置的packageTaskSettings

于 2014-08-09T17:42:53.817 回答