3

I use package task (from xsbt-web-plugin) to package a project to a war, and assembly task (from sbt-assembly) to package the project to a jar.

I have a multi-module build and some modules are packaged into wars and some into jars.

I'd like to set up the build to execute assembly task and:

  • Jar modules are packaged into jar files
  • War modules are packaged into war files

How to execute package task for the war projects while executing assembly task?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Cherry
  • 31,309
  • 66
  • 224
  • 364
  • Could you simply make `assembly` depend on the `package` task for each webapp project? see: http://www.scala-sbt.org/0.12.2/docs/Detailed-Topics/Tasks.html#dependencies – earldouglas Dec 30 '14 at 05:53

1 Answers1

1

Both package task and assembly task evaluate to File type, so as @James commented you should be able to rewire assembly task in webapp project to run package instead.

lazy val commonSettings = Seq(
  scalaVersion := "2.11.4"
)
lazy val webappAssembly = Seq(
  assembly := packageWar.value
)

lazy val root = (project in file(".")).
  aggregate(app, webapp).
  settings(commonSettings: _*)

lazy val app = (project in file("app")).
  settings(commonSettings: _*)

lazy val webapp = (project in file("webapp")).
  settings(commonSettings ++ jetty() ++ webappAssembly: _*).
  settings(
    libraryDependencies += "javax.servlet" % "javax.servlet-api" % "3.0.1" % "provided"
  )
Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319