How to “package” some modules to jars and others to wars in multi-module build with single task?

无人久伴 提交于 2019-12-07 13:01:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!