-
Hi, I'm new to mill (0.12.14) and trying to convert some of my sbt projects to mill. I've come to a few points I cannot solve. One is, I'd like to know how to do the cli I tried with a root module that contains my other modules and I would like to define a single command that runs some tasks on all child modules. But I'm stuck trying to run tasks on my "child modules", like all tests or all checkformats: object `package` extends RootModule {
def ci() = Task.Command {
// run __.checkStyle
// run __.test
}
object module1 extends ScalaModule with StyleModule {}
object module2 extends ScalaModule with StyleModule {
object test extends ScalaTests with TestModule.MUnit {
// ...
}
}
} I know from the cli I can use "command queries" like I was playing with the Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
If you already have a handle to all modules, using def myTestModules: Seq[TestModule]
def ci() = Task.Command {
// run __.test
Task.traverse(myTestModules)(_.testForked())()
} If you don't have the modules, you can use an evaluator command to find these modules. (Please note, that this API will slightly change in Mill 1.0.) import mill.eval.{Evaluator, Terminal}
import mill.resolve.{Resolve, SelectMode}
def ci(evaluator: Evaluator) = Task.Command {
Resolve.Tasks.resolve(
evaluator.rootModule,
Seq("__.testForked"),
SelectMode.Separated
) match {
case Left(err) => Task.fail(err)
case Right(resolved) =>
Task.sequence(resolved)()
}
} (I haven't actually run these examples, so there might be typos or errors in it) |
Beta Was this translation helpful? Give feedback.
-
Hi @lefou thank you very much for your quick reply!! Unfortunately, I'm still not much further. I tried your code and what is written at the documentation you linked to. The snippet above (slightly modified to fit to 0.12.14) fails with
So I moved the resolving outside the def ci(ev: Evaluator) = {
val tests: List[mill.define.NamedTask[Any]] = Resolve.Tasks
.resolve(
ev.rootModule,
Seq("__.test"),
SelectMode.Separated
)
.fold(sys.error, identity)
println(s"Found ${tests}")
Task.Command {
Task.sequence(tests)()
()
}
} This compiles and runs without errors, but there are no tests run. I noticed that a
I also tried with naming my modules directly: def ci2()= Task.Command {
Task.traverse(List(server.test, common.test, store.test))(_.test())()
} It shows the same effect: no errors from mill, but no tests run either. |
Beta Was this translation helpful? Give feedback.
If you already have a handle to all modules, using
Task.traverse
should be enough to get these tasks handled as prerequisites, and executed if not up-to-date.If you don't have the modules, you can use an evaluator command to find these modules. (Please note, that this API will slightly change in Mill 1.0.)