scalasbtxsbt-web-plugin

Web App Subproject


When the servlet container is started using xsbt-web-plugin, it adds the context for <root dir>/target/webapp. I have a multiproject set up where the web app is a subproject. How is the context added for a subproject instead of the root project?


Solution

  • In a multi-module sbt project where xsbt-web-plugin is added to one of the submodules, the webapp directory will be created under <project>/<submodule>/target/webapp.

    An example multi-module project can be found in the scripted tests directory. In this example, the project is called multi-module-single-webapp, and the Web submodule is called mathsweb, so the webapp directory can be found under multi-module-single-webapp/mathsweb/target/webapp.

    To have sbt show you the full path of the webapp directory, you can run show webappPrepare at the sbt prompt:

    sbt:root> show webappPrepare
    ...
    [info] * (/home/james/code/multi-module-single-webapp/mathsweb/target/webapp,)
    ...
    

    You can optionally specify the Web submodule name:

    sbt:root> show mathsweb/webappPrepare
    ...
    [info] * (/home/james/code/multi-module-single-webapp/mathsweb/target/webapp,)
    ...