Suma
Suma

Reputation: 34393

SBT war deployment with xsbt-web-plugin

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?

Upvotes: 0

Views: 1816

Answers (1)

Suma
Suma

Reputation: 34393

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.

Upvotes: 0

Related Questions