Overriding port settings when using Build.scala files

I move my assembly from build.sbt files to Build.scala, and I am having problems redefining port settings 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 tried several things, but the berth always starts at 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 also tried to override it in the project definition in Build.scala:

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

But it always starts with 8080. In both cases, the start of show port shows 8081.

+4
source share
1 answer

The problem is that the web plugin hides its port setting inside the configuration. It allows you to use several containers with different port settings. However, it does not pull a port from a non-scoped key (like many plugins).

So you have to explicitly do:

port to: = 8081

On the sbt console, if you are doing an inspect tree in the task of starting the server, you will probably see somewhere that it relies on the setting of <config>:part .

I think by default you want:

 port in container.Configuration := 8081 

If you are in a .scala file, you may also need to include the file with Container , i.e.

 import com.earldouglas.xsbtwebplugin.WebPlugin.container 

I also recommend opening a feature request in a web plugin to automatically delegate the port setting to Global and specify the default there for the default web plugin.

You can simulate this yourself with these two settings:

 port in container.Configuration := port in Global port in Global := 8081 

Hope this helps!

+5
source

All Articles