jettysbtmaven-jetty-pluginxsbt-web-plugin

how to set the contextPath of jetty on xsbt-web-plugin?


I'm on sbt 0.11.1 and xsbt-web-plugin 0.2.10

here goes the build.sbt and plugins.sbt

build.sbt

organization := "org"

name := "demo"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.9.1"

seq(webSettings :_*)

configurationXml := 
                    <configuration>
                        <webApp>
                          <contextPath>/foo</contextPath>
                        </webApp>
                    </configuration>

libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "7.4.5.v20110725" % "container",
  "javax.servlet" % "servlet-api" % "2.5" % "provided"
)

resolvers += "Sonatype OSS Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

project/plugins.sbt

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))

It seems the configurationXml doesn't work, after running container:start in sbt console, the contextPath gets the default value "/"

how can I change the contextPath? any tips? thanks in advance!


Solution

  • Here's a solution from scalatra-user group

    Add jetty-plus to dependencies:

    "org.eclipse.jetty" % "jetty-plus" % "7.4.5.v20110725" % "container"
    

    Add this to build.sbt:

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

    In the same directory as build.sbt, create the jetty-env.xml:

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