I'm looking for a way to create a custom command in sbt for multi-project structure in a such way:
- This command shouldn't do anything for the root project
- This command should make some action in subprojects
- Executing command for the root project should trigger execution such commands for subproject
I have this in my build.sbt
lazy val root = (project in file("."))
.settings(
name := "Custom command",
commands += Command.command("customCommand") { state =>
state
}
)
.aggregate(a, b)
lazy val a = project
.settings(
commands += Command.command("customCommand") { state =>
println("Hello")
state
}
)
lazy val b = project
.settings(
commands += Command.command("customCommand") { state =>
println("Hey there")
state
}
)
Unfortunately, I get nothing in the sbt shell:
sbt:Custom command> customCommand
sbt:Custom command>
The expected output is:
sbt:Custom command> customCommand
Hello
Hey there
sbt:Custom command>
The order doesn't matter.
So it looks like my command is executed for the root
project only. Is there any way to tell sbt to execute customCommand
for subproject first?