Gradle7に上げたら暗黙の依存性が云々と言われた件

gradleのversionを6系から7系に上げてbuildしたところ、

Task ':taskX' uses this output of task ':taskY' without declaring an explicit or implicit dependency. 
This can lead to incorrect results being produced, depending on what order the tasks are executed. 
Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.

こんなメッセージが出るようになった。 taskXがtaskYに暗黙的に依存しているよ、結果は保証しないよ、的なメッセージだ。

buildが失敗するわけではないが、結果が不安定になるのは良くない。

しかし、解消したいものの、taskX, taskYが自分で作ったものでない場合…pluginで定義されているものを使っている場合も多々ある。

ではどうするか。

あとから依存性を明示してあげればいい。

以下はbuild.gradle.ktsの例。

tasks.named("taskX") { dependsOn("taskY") }