How can I tell sbt to exclude files from the WAR but allow them to be loaded by container:start?

StackOverflow https://stackoverflow.com/questions/9401934

  •  29-10-2019
  •  | 
  •  

Question

I have an an sbt 11.0 project that I originally wrote again xsbt-web-plugin 0.1.x. Against that version I was able to use the following line to cause some files not to be included in the WAR but to be loaded when I did jetty-run.

WebPlugin.webappUnmanaged <<= WebPlugin.temporaryWarPath{twp => (twp / "api" / "1" / "javascript" / "test" * "*") }

In xsbt-web-plugin version 0.2.x there isn't a WebPlugin.webappUnmanaged key. Do you know how I could accomplish the same thing with the new version?

So in case it wasn't clear, what I'm trying to do is load some test JavaScript when I'm running Jetty from within SBT, but I want to exclude those files from the artifact produced by package-war so that the test files don't go to production.

Was it helpful?

Solution

It seems what you need to do is use the warPostProcess setting and delete the appropriate files. I believe in your case it would look like the following:

warPostProcess in Compile <<= (target) map {
  (target) => { 
    () =>
    val webapp = target / "webapp"
    IO.delete(webapp / "api/1/javascript/test")
  }
}

This snippet was taken from here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top