简体   繁体   中英

xsbt-web multi-module project: package some modules to jars, others to wars

I'm using sbt 0.13.8 and xsbt-web-plugin 2.0.3

I have a multi-module sbt project. When packaged, one of the modules should be in the form of a war file. All of the others in jar files.

When I add the xsbt-web plugin, packaging generates jars and wars for all modules. How can I tell the xsbt-web plugin to apply itself only to the module that should be packaged as a war?

I've already found one solution, which is to mutate the packagedArtifacts list for each non-war module:

packagedArtifacts <<= packagedArtifacts map { as => as.filter(_._1.`type` != "war") }

However, this is a non-local change which I would have to apply to each new non-war module that I (or a team member) might create.

I do not consider this a duplicate of the StackOverflow issue How to “package” some modules to jars and others to wars in multi-module build with single task? since I am not using assembly.

Note that the jars for the jar modules and the wars for the war modules, which are currently being generated, work splendidly. I'm only trying to avoid the situation where somebody tries to deploy a war that was meant to be a jar.

This was a bug in version 2.0.3 -- thanks for discovering it! I've fixed it in 2.0.4.

To enable .war file publishing for a single module in a multi-module project:

  1. Add xsbt-web-plugin in project/plugins.sbt
  2. Enable the WarPlugin plugin in [webproject]/build.sbt

project/plugins.sbt:

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

[webproject]/build.sbt:

enablePlugins(WarPlugin)

You can find a full example of this at https://earldouglas.com/ext/stackoverflow.com/questions/31683637/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM