Hello, I have a problem. Is there a way from root...
# gradle
i
Hello, I have a problem. Is there a way from root project to check whether every sub project has one gradle plugin declared ?
d
not an expert but you could probably do something like
subprojects.filterNot { it.pluginManager.hasPlugin("yourPluginName") }.isEmpty()
in
build.gradle.kts
(or check for existence of tasks, etc)
g
What is your use case for this?
i
I am developing a gradle plugin to config a task parameter, then i use another gradle plugin to consolidate these parameters to generate every task inside one application, is it doable?
g
Still not clear for me why you want to check that every sub project has a plugin. Probably you should react on plugin application instead, you can use plugins.withType(SomeType) to know when plugin is applied, because it may be lazy action, you shouldn't rely on plugins application order, it's not guaranteed
Also all actions with all subprojects (such as subprojects/allprojects block) break configuration on demand, I would avoid this practice and apply plugin to every module explicitly
i
you are right, it might be not efficient to do so, what you would recommend to implement this situation, to consolidated the individual configurations from sub project and generate the tasks inside another project to use these parameters
g
Every project should create own task with the same name and you will run them together by ./gradlew taskName, which will execute tasks on every module. Connect modules using top level project is possible, but looks like a hack for me