11

I have the following project structure:

lazy val root = project.aggregate(rest,backend)
lazy val rest = project
lazy val backend = project

When I execute the "run" task from the parent, I want a specific class from the "backend" project to have its main method executed. How would I accomplish this?

Robin Green
  • 32,079
  • 16
  • 104
  • 187
ThaDon
  • 7,826
  • 9
  • 52
  • 84

1 Answers1

6
lazy val root = project.aggregate(rest,backend).dependsOn(rest,backend) //<- don't forget dependsOn
lazy val rest = project
lazy val backend = project.settings(mainClass in (Compile, run) := Some("fully.qualified.path.to.MainClass"))

run in Compile <<= (run in Compile in backend)
Schleichardt
  • 7,502
  • 1
  • 27
  • 37
  • Why is the `dependsOn` from root to `backend` important? The last line seems to work for me, also without it (i.e. `sbt clean` followed by `sbt run` does the right thing). – akauppi Mar 02 '16 at 08:44
  • 1
    "<<=" operator was removed from sbt 1.x – zella Apr 13 '18 at 22:52