I have some global config write in allProjects block in the root build.gradle.kts
. Then I add some specified config in some children. But looks the allProjects is execute after all children. So I can’t achive my goal in this way.
Are there any way to achive my goal? Thank you
Shouldn’t be executed after the children, but indeed before.
But anway, using allprojects { ... }
or subprojects { ... }
is bad practice and discouraged.
You should use convention plugins instead, for example implemented as precompiled script plugins in buildSrc
or an included build.
For example I want to disable all dist* task default. But only a few subproject. Should I create a precompiled script plugin for it?
Whether you do it as precompiled script plugin, or as “normal” plugin or however doesn’t really matter. But if you are asking whether you should do it as convention plugin, then yeah, definitely. Code that convention in a convention plugin, then apply that convention plugin directly in those subprojects’ build scripts where that convention should be in effect.