问题
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?
回答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"
)
来源:https://stackoverflow.com/questions/27631989/how-to-package-some-modules-to-jars-and-others-to-wars-in-multi-module-build-w