1

I trying to create custom configuration for jetty when using sbt-web-plugin (for running with container:start). There are two container settings allowing to specify custom jetty xml configuration: configurationFiles and configurationXml (when customConfiguration is true).

However, this overrides internal configuration of jetty done by sbt-web-plugin completely so custom config should configure jetty fully. And it will not work without specifying classpath to .class files compiled from project and to dependencies.

I trying to do something like that:

configurationXml in container.Configuration <<= fullClasspath (
  <Configure id="Server" class="org.eclipse.jetty.server.Server">
    ...
    <Set name="handler">
      <New class="org.eclipse.jetty.webapp.WebAppContext">
        <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/src/main/webapp</Set>
        <Set name="descriptor"><SystemProperty name="jetty.home" default="."/>/src/main/webapp/WEB-INF/web.xml</Set>
        <Set name="contextPath">/</Set>
        <Set name="extraClasspath">{/* classpath should be here */}</Set>
      </New>
    </Set>
    ...
  </Configure>
)

Seems that direct dependency of configurationXml on fullClasspath is not possible, because configurationXml is SettingKey and fullClasspath is TaskKey:

Tasks with dependencies

The practical importance of this is that you can't have tasks as dependencies for a non-task setting.

Is it possible to include fullClasspath setting in configurationXml parameter?

If not, is it still possible to add custom configuration settings to jetty development server invoked on container:start?

kolen
  • 2,752
  • 2
  • 27
  • 35

1 Answers1

2

You can customize just the WebAppContext using the env setting:

env in Compile := Some(file(".") / "jetty-env.xml" asFile)

For example, consider the following in myproject/jetty-env.xml:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/custom</Set>
</Configure>

This will deploy your webapp under the context path /custom, but won't change any configuration of the underlying Server.

earldouglas
  • 13,265
  • 5
  • 41
  • 50
  • Where is this `env` setting documented? – aij Aug 12 '16 at 16:51
  • You can find it in the [docs for version 0.9](https://github.com/earldouglas/xsbt-web-plugin/blob/master/docs/0.9.md#web-application-settings), but that's pretty old and deprecated. I'll look into updating this for 2.1. – earldouglas Aug 12 '16 at 20:16