为什么检查编译:使用xsbt-web-plugin时,在Sbt控制台中packageWar :: packagedArtifact会失败?

时间:2014-08-09 06:05:54

标签: scala sbt xsbt-web-plugin

我正在使用xsbt-web-plugin和Sbt 0.13.2。如果我将以下内容添加到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,但实际上并没有造成问题。)

1 个答案:

答案 0 :(得分: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任务set up indirectly使用packageTaskSettings