sbt:在子项目上运行任务

时间:2013-11-21 21:20:18

标签: sbt

我有以下项目结构:

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

当我从父级执行“运行”任务时,我希望“后端”项目中的特定类执行其main方法。我该如何做到这一点?

1 个答案:

答案 0 :(得分: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)