How to define a task which needs to run other tasks sequentially #4432
-
Mill version: 0.12.5 Since 0.12.0 update, Mill has switched to parallel task execution by default. This has broken my build, so I intitally switched to Now I am trying to re-write my task definitions so that they work sequentially where that is required. For example, I have a custom compile tasks which is supposed to first run flywayMigrate, then generate code, and finally compile the module. Until now, this is how I defined that compile task: override def compile = Task(persistent = true) {
flywayMigrate()()
generateJooq()()
super.compile()
} This is now arbitrartily failing most of the time, because the code is not generated before I have tried rewriting this using override def compile = Task(persistent = true) {
Task.sequence(
Seq(
flywayMigrate().map(_ => None),
generateJooq().map(_ => None),
super.compile.map(Some(_))
)
).apply().last.get
} But the result is the same. Is there any way to specify in the build logic that some tasks need to preceed other ones like in the case above? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The basic approach is that dependent tasks need to call each other. So See the docs for examples of how generating sources is meant to work. From your description you aren't doing it the normal way, but it should be easy to follow the normal pattern This will ensure the tasks get run in the right order despite parallelism/caching |
Beta Was this translation helpful? Give feedback.
The basic approach is that dependent tasks need to call each other.
So
def generateJooq
should callflywayMigrate()
, anddef compile
should callgenerateJooq()
(perhaps indirectly throughdef generatedSources
)See the docs for examples of how generating sources is meant to work. From your description you aren't doing it the normal way, but it should be easy to follow the normal pattern
This will ensure the tasks get run in the right order despite parallelism/caching