PlexQ
PlexQ

Reputation: 3110

What is the best way to handle multiple run targets in SBT?

I'm attempting to create a Build.scala that has multiple projects/targets for the run action. I had started trying to define it as a sub-project like:

val this_one = Project(
    id = "Main",
    base = file(".")
    settings = ...
)

My first guess is that I have the wrong settings stuff, or the config doesn't belong in a Project definition like this.

To elaborate a little, I have more than one main() I want to run in a single source tree. There are a couple of tools that go with the main project itself, and I would like to be able to execute them selectively from the sbt console.

Upvotes: 3

Views: 361

Answers (2)

Bienvenido David
Bienvenido David

Reputation: 4348

You can specify the main class using run-main. Something like:

sbt "run-main com.company.project.Main1"

sbt "run-main com.company.project.Main2"

Upvotes: 0

PlexQ
PlexQ

Reputation: 3110

Turns out SBT is just smart enough to figure it out by itself! If you have multiple classes with a main(), it gives you a choice when you type "run" at the SBT prompt!

Upvotes: 1

Related Questions