0

I have configured by SBT project to use xsbt-web-plugin for web deployment. The docs describing this seem to be:

xsbt-web-plugin Wiki

Publishing .war files

This is what I have done so far based on reading docs:

I have created plugins.sbt with:

resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"

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

Added following lines into build.sbt:

Seq(webSettings :_*)


// disable .jar publishing
publishArtifact in (Compile, packageBin) := false

// create an Artifact for publishing the .war file
artifact in (Compile, packageWar) := {
  val previous: Artifact = (artifact in (Compile, packageWar)).value
  previous.copy(`type` = "war", extension = "war")
}

// add the .war file to what gets published
addArtifact(artifact in (Compile, packageWar), packageWar)

When loading the project with sbt, the plugins gets downloaded, but then following error is reported:

[error] Reference to undefined setting:
[error]
[error]   *:packageWar from *:$local (W:\Tempi\TempiJetty\build.sbt:48)
[error]      Did you mean compile:packageWar ?

Writing compile:packageWar instead of packageWar in the last line causes different error:

[info] Loading project definition from W:\Tempi\TempiJetty\project
W:\Tempi\TempiJetty\build.sbt:48: error: not found: type packageWar
addArtifact(artifact in (Compile, packageWar), compile:packageWar)
                                                       ^
[error] Type error in expression

What should I write so that my SBT project supports war packaging?

Suma
  • 33,181
  • 16
  • 123
  • 191

1 Answers1

0

It seems even when I remove the final line addArtifact(artifact in (Compile, packageWar), packageWar), the package command in the sbt still builds the war file. This might be new or specific to SBT 0.13 I am using (the docs seem to be older), or perhaps the intention was to pack the war file even with compile command, which I do not need.

Suma
  • 33,181
  • 16
  • 123
  • 191
  • 1
    Hi Suma, would you clarify the question? I maintain xsbt-web-plugin so I want to make sure the docs are as helpful as can be. Your question sounds like you want to build a WAR file, but your comment sounds like you want to *avoid* building a WAR file. What's the desired goal? Does it have to do with packaging the WAR file? Are you interested in deploying a WAR file to a server? – earldouglas Apr 28 '14 at 16:11
  • @James I want to build a war file (it is done on the Jenkins, and the war is then deployed using an ant build). I do not quite understand what is necessary for that. Perhaps the part mentioned in the "Publishing .war files" is not necessary at all? – Suma Apr 28 '14 at 19:54
  • 1
    In that case, all you need to run is `package` from sbt, or `sbt package` from the command line. This will generate a WAR file under *target/scala_2.10/...*. In your *build.sbt* above, you shouldn't need anything other than `seq(webSettings :_*)`. – earldouglas Apr 29 '14 at 04:38
  • 1
    You might also find the [instructions for building a minimal xsbt-web-plugin application](https://github.com/earldouglas/xwp-template#getting-started-with-xsbt-web-plugin) helpful. They walk you through the configuration, all the way to building a WAR file at the end. – earldouglas Apr 29 '14 at 04:41