sbt: run task on subproject
Asked Answered
A

1

12

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?

Anacrusis answered 21/11, 2013 at 21:20 Comment(0)
P
7
lazy val root = project
  .aggregate(rest, backend)
  .dependsOn(rest, backend) //<- don't forget dependsOn
lazy val rest =
  project
lazy val backend =
  project.settings(
    Compile / run / mainClass := Some("fully.qualified.path.to.MainClass")
  )

Compile / run := (backend / Compile / run).evaluated
Piefer answered 21/11, 2013 at 22:50 Comment(3)
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).Googly
"<<=" operator was removed from sbt 1.xUnbolted
Re: the removal of <<=, I've done by best to update the answer to use modern sbt 1 syntax.Particia

© 2022 - 2024 — McMap. All rights reserved.