I have a multiproject gradle configuration and I wanted to add a plugin to all subprojects and the root project as well. Reading the docs here seems to be easy:
If you have a multi-project build, you probably want to apply plugins to some or all of the subprojects in your build, but not to the root or master project. The default behavior of the plugins {} block is to immediately resolve and apply the plugins. But, you can use the apply false syntax to tell Gradle not to apply the plugin to the current project and then use apply plugin: «plugin id» in the subprojects block or use the plugins {} block in sub projects build scripts
So basically the docs say: Apply false
to only include the subprojects, don't apply anything and the plugin will be applied to all projects.
But this isn't working for me, I have to define the plugin at the root project build.gradle
and then reapply it again in all subprojects, is this a bug?
allprojects { apply plugin: 'myplugin' }
in the root project – Aureolinapply false
, the plugin is "imported", but not applied to the root project. It can then be explicitly applied to subprojects (usingapply plugin..
) – Aureolinapply true
, or noapply
at all? We can infer from the docs that the plugin will be "imported", applied to the root project and all subprojects.... afterall,true
should make the opposite of whatfalse
does. – Deberadeberryapply
the plugin- so you can omitapply true
and the plugin is applied (and if you think of it, this is what happens whenever youapply plugin: 'java'
to any project- the plugin is applied) – Aureolinallprojects
block – Deberadeberry