I have a multi-project sbt build (each project is micro service). For development convenience, I want to run all of them at the same time. Is it possible with sbt?
lazy val root = (project in file("."))
.aggregate(
serviceA,
serviceB
)
lazy val serviceA = (project in file("service-a"))
...
lazy val serviceB = (project in file("service-b"))
...
I can run them individually with serviceA/run
or serviceB/run
But I need to run serviceA and serviceB with single sbt command (they will be running on different ports)
By default, sbt executes tasks in parallel (subject to the ordering constraints already described) in an effort to utilize all available processors. Also by default, each test class is mapped to its own task to enable executing tests in parallel.
clean Deletes all generated files (in the target directory). compile Compiles the main sources (in src/main/scala and src/main/java directories). test Compiles and runs all tests. console Starts the Scala interpreter with a classpath including the compiled sources and all dependencies.
A project is defined by declaring a lazy val of type Project. For example, : lazy val util = (project in file("util")) lazy val core = (project in file("core")) The name of the val is used as the subproject's ID, which is used to refer to the subproject at the sbt shell.
You could try to use Ammonite
We us Ammonite scripts (e.g. runner.sc
) to run sbt. I never used Future
as we run one thing after the other.
Or use a simple bash file:
Your requirement is more or less running sbt in the background. Here is an according question: how-to-run-sbt-as-daemon
Taking this to your question, this could look like:
#!/usr/bin/env bash
sbt -Djline.terminal=jline.UnsupportedTerminal serviceA/run &
sbt -Djline.terminal=jline.UnsupportedTerminal serviceB/run &
I couldn't test this, let me know if it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With