earldouglas / xsbt-web-plugin

Servlet support for sbt
BSD 3-Clause "New" or "Revised" License
382 stars 105 forks source link

containerArgs not working for jetty #358

Closed evanthomas closed 6 years ago

evanthomas commented 6 years ago

I'm trying to pass additional config to jetty as follows

containerArgs in Jetty := Seq("--config", "etc/jetty.xml", "--config", "etc/jetty-https.xml", "--config", "etc/jetty-ssl.xml")

It is being ignored.

Here is my plugins.sbt:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
addSbtPlugin("org.scalatra.scalate" % "sbt-scalate-precompiler" % "1.8.0.1")
addSbtPlugin("org.scalatra.sbt" % "scalatra-sbt" % "0.5.1")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.1")

Here is my build.sbt:

import org.fusesource.scalate.ScalatePlugin.ScalateKeys._

val ScalatraVersion = "2.5.1"
lazy val akkaVersion = "2.5.4"

resolvers += Classpaths.typesafeReleases
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"

lazy val root = (project in file("."))
    .settings(
        name := "multi-runner",
        version := "0.0.1-SNAPSHOT",
        scalaVersion := "2.12.3",
        libraryDependencies ++= Seq(
      "org.scalatra" %% "scalatra" % ScalatraVersion,
      "org.scalatra" %% "scalatra-auth" % ScalatraVersion,
      "org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
      "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
      "com.typesafe.akka" %% "akka-actor" % akkaVersion,
            "com.typesafe.akka" %% "akka-testkit" % akkaVersion,
      "com.typesafe.akka" %% "akka-stream" % akkaVersion,
      "org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container;compile",
      "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
      "com.typesafe.play" %% "play-json" % "2.6.3",
      "org.scalatest" %% "scalatest" % "3.0.1" % "test",
            "com.amazonaws" % "aws-java-sdk-s3" % "1.11.188",
      "commons-codec" % "commons-codec" % "1.10"
        ),
        organization := "co.mumbler"
    )

scalateTemplateConfig in Compile := {
  val base = (sourceDirectory in Compile).value
  Seq(
    TemplateConfig(
      base / "webapp" / "WEB-INF" / "templates",
      Seq.empty,  /* default imports should be added here */
      Seq(
        Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
      ),  /* add extra bindings here */
      Some("templates")
    )
  )
}

mainClass in Compile := Some("Main")

javaOptions ++= Seq(
  "-Xdebug",
  "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
)

enablePlugins(JettyPlugin)
containerArgs in Jetty := Seq("--config", "etc/jetty.xml", "--config", "etc/jetty-https.xml", "--config", "etc/jetty-ssl.xml")

TIA - Evan.

earldouglas commented 6 years ago

Your configuration looks valid to me. I tried it out using this jetty.xml and it worked as expected.

A few considerations:

evanthomas commented 6 years ago

@earldouglas jetty is starting and loading etc/jetty.xml however it is doing that anyway, even if no config arguments are specified. There are no exceptions unless I deliberately make my jetty.xml malformed. I should also point out this is on windows 10. I’ll test on a Mac later today.

evanthomas commented 6 years ago

@earldouglas It looks like I wasn't refreshing the sbt shell and so it wasn't registering the args.

False alarm - sorry.

earldouglas commented 6 years ago

Cool; glad you got it figured out. Is there anything I can update in the docs that would have helped you with this?

evanthomas commented 6 years ago

Your docs are very good - succinct and to the point. It was just me not fully understanding my own dev environment and if you try and cover every stupid thing someone might do, your docs will no longer be succinct and to the point :) By the way, your jetty.xml is brilliant. Like many people (it seems), I was trying to get a basic https/ssl up and running and there is dearth of good, working examples. Yours just works so thanks for that as well.