Teimuraz
Teimuraz

Reputation: 9325

How to run multiple sbt projects in parallel?

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)

Upvotes: 7

Views: 1164

Answers (1)

pme
pme

Reputation: 14803

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.

Upvotes: 1

Related Questions