1

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.)

Integrator
  • 519
  • 5
  • 14
  • Can you print the error message? What's inside `build.sbt` is scoped to the project the build file is in so it may contribute to what you experience...somehow. – Jacek Laskowski Aug 09 '14 at 12:15
  • do you have `warSettings` in your build file? – wedens Aug 09 '14 at 15:29
  • I have added the requested information. I have also tried adding warSettings to build.sbt, I did not see any changes as a result. – Integrator Aug 09 '14 at 16:20

1 Answers1

2

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.

earldouglas
  • 13,265
  • 5
  • 41
  • 50
  • Thanks, I now see the scala variable is named packageWar, but the name it is given is "package". And the war stuff seems to be in global scope *:package, while the original jar stuff stays in compile:packageBin. – Integrator Aug 09 '14 at 22:34