简体   繁体   中英

Why does inspect compile:packageWar::packagedArtifact fail in the Sbt console when using xsbt-web-plugin?

I am using xsbt-web-plugin with Sbt 0.13.2. If I add the following to build.sbt I can type "myTask" in the console and it works:

val myTask = taskKey[Unit]("My task.")

myTask :=  {
  val (art, file) = packagedArtifact.in(Compile, packageWar).value
  println("Artifact definition: " + art)
  println("Packaged file: " + file.getAbsolutePath)
}

But why does this return an error if I type it in the Sbt console?

inspect compile:packageWar::packagedArtifact

Error message:

[error] Expected key
[error] Not a valid key: packageWar (similar: package, packageSrc, package-src)
[error] inspect compile:packageWar::packagedArtifact
[error]                           ^

For comparison, this one does work:

inspect compile:packageBin::packagedArtifact

Key parts of 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)
}

project/plugins.sbt:

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "1.0.0-M4")

(I'm only asking so that I can understand Sbt better, it's not actually causing a problem.)

You can get this info from package rather than 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.

The packageWar task is set up indirectly using packageTaskSettings .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM