4

I am moving my build from build.sbt to Build.scala files and I am having trouble overriding the jetty port setting when using the xsbt-web-plugin. When using build.sbt I was able to set the property using:

port in container.Configuration := 8081

In my .scala files I have tried a few things but jetty is always starting on 8080 for example in my BuildSettings object:

import sbt._
import Keys._
import com.earldouglas.xsbtwebplugin.PluginKeys._
object BuildSettings {
  lazy val settings =  com.earldouglas.xsbtwebplugin.WebPlugin.webSettings ++ seq(
    ...
    port := 8081,
    ...
  ) 
}

I have also tried overriding it in the Project definition in Build.scala:

  lazy val root = Project("test",file("."))
    .settings(settings: _*)
    .settings(port := 8081)

But it always starts on 8080. In both of these cases running show port shows 8081.

Leesrus
  • 1,095
  • 2
  • 11
  • 19
  • Have you tried to use port in container.Configuration := 8081 like in your build.sbt? – Christian Sep 26 '13 at 14:49
  • I don't have a build.sbt in my project, I have moved to entirely .scala files rather than a mixed configuration. – Leesrus Sep 26 '13 at 15:02
  • I know. But you said it worked. So why not try to write it in your scala file in the same way (including in container.Configuration)? – Christian Sep 27 '13 at 09:21

1 Answers1

5

The issue is the web plugin is hiding its port setting inside a configuration. It allows multiple containers with different port settings. However, it is not pulling the port from the non-scoped key (as do a lot of plugins).

So you'll have to explicitly do:

port in := 8081

On the sbt console if you do inspect tree on the server startup task, you'll probably see somewhere that it relies on <config>:part setting.

I think by default, you want:

port in container.Configuration := 8081

If you're in a .scala file you may also need to include the file which has Container, i.e.

import com.earldouglas.xsbtwebplugin.WebPlugin.container

I'd also recommend opening a feature request on the web plugin to automatically delegate the port setting to Global and specify the default there, for the default Web plugin.

You can mimic this yourself with these two settings:

port in container.Configuration := port in Global

port in Global := 8081

Hope that helps!

jsuereth
  • 5,604
  • 40
  • 40