How to have different webapp resources for container:start and package tasks in SBT

帅比萌擦擦* 提交于 2019-12-12 17:26:05

问题


I have a web application with pure JS frontend and Scala backend. I would like to use Grunt in my build pipeline to process src/main/webapp into target dist/webapp dir with concatenated/minified js and html files, compiled sass sheets etc. I also want to preserve original JS and HTML files for local testing using container:start task, while the package task would build my WAR file with resources processed by Grunt. When I use following setting in SBT:

webappResources in Compile <<= baseDirectory { bd => Seq(bd / "dist" / "webapp") }

then I achieve the second goal - my WAR gets built using the webapp resources in dist/webapp. However, when using container:start during local development I get bound to the same directory. Is there any way to define different dirs for different purposes?


回答1:


xsbt-web-plugin supports SBT 0.13.1 so you can use the much-nicer syntax to define webappResources in the Compile scope:

webappResources in Compile := Seq(baseDirectory.value / "dist" / "webapp")

I might be mistaken, but webappResources alone would work, too.

webappResources := Seq(baseDirectory.value / "dist" / "webapp")

or even (unless you want to replace the original value not to append a value):

webappResources += baseDirectory.value / "dist" / "webapp"

As for the solution I'd use the following (untested) in build.sbt:

webappResources in package := Seq(baseDirectory.value / "dist" / "webapp")

and leave the default value for the webappResources setting for local development.

Read Scopes to learn more about "scoping" settings, i.e. setting different values for different axes.



来源:https://stackoverflow.com/questions/20996993/how-to-have-different-webapp-resources-for-containerstart-and-package-tasks-in

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