Akka cluster + SBT 1.6.0+

I tried to create a project from scratch and with the dependencies of the latest versions.

There were problems with running a minimal application with a cluster and a http server.
sbt run exits immediately.

I found some changes, then I tried 1.5.8 (all is fine) and 1.6+ (exits)

fork := true starts work http server but cannot connect cluster

I didn’t find any examples with sbt 1.6.0+ version
What is the right config for build.sbt with sbt 1.6.0+ when using a cluster with an http server and using sbt run in developing

fork := true should do the trick with leaving the actor system running after main completes with sbt 1.6.0+

The akka quickstart g8 templates should all be updated with fork and a recent sbt already but I noticed we missed it in the samples repo, which is already on sbt 1.7.2, this PR fixes the fork there: fix: Fork run and allow ctrl+c cancel by johanandren · Pull Request #273 · akka/akka-samples · GitHub

Bootstrapping a cluster can be done in several different ways, programatic, through config or through Akka Management/cluster bootstrap. See docs for cluster bootstrap which most likely is what you want to use in the end: Akka Cluster Bootstrap • Akka Management

The basic cluster sample uses config based bootstrap, which is less likely something that you would use for a production system but is simpler to set up: akka-samples/akka-sample-cluster-scala at main · akka/akka-samples · GitHub

I can not understand how to pass -Dconfig.resource to impl project in “fork:=true” mode with command line.

lazy val `root` = (project in file(".")).aggregate(`api`, `impl`)

lazy val `api` = (project in file("api"))

lazy val `impl` = (project in file("impl"))

sbt -Dconfig.resource=local1.conf impl/run is not worked now.

Yeah, that is a bit tricky, there is no forwarding of system properties from sbt to forked processes by default, so you’ll either have to hardcode such, if you know you’ll want the same each time you run, or if you want to specify different ones write some logic to read some subset of the properties and forward those.

For some inspiration we do that in the Akka build itself here (but you’ll want them for run / javaOptions rather than for test / javaOptions): akka/AkkaBuild.scala at e3833cae03bd1391a63820b06ae4cdca0d20079e · akka/akka · GitHub

Another option can be to push the logic into you main method, like the akka-cluster-sample stats app for example: akka-samples/App.scala at main · akka/akka-samples · GitHub

Thank you very much.
I’ve found something same (jvm options not passed on to forked process) now, but your proposed solution is more elegant.