0

I'd like sbt to generate two packages:

  1. A WAR file, for the web app
  2. A JAR file, which has command line and batch code

The two packages share a lot of similar code (the business logic) and dependencies, but of course the Servlet aspects are only in the WAR, and the command line and batch only in the JAR.

I'd like the JAR to run by itself, no external dependencies required (ala sbt-assembly).

How can I do this?

SRobertJames
  • 8,210
  • 14
  • 60
  • 107

1 Answers1

0

WAR file

You can make a war file using earldouglas/xsbt-web-plugin and use sbt-assembly for fat JAR. You might have to get a bit creative to include some files in one but exclude from the other.

Generating JAR and WAR from the same code base

If the resulting packages contain different library dependencies at the end, for example including Jetty or Netty for standalone JAR, I think it needs to be a separate subproject. See Multi Project builds.

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319