No need to provide an MCVE here.
What you hit is that it should imho actually fail if you try to do that from a precompiled script plugin: Plugins block apply plugins automatically despite "apply false" for precompiled script plugins · Issue #14437 · gradle/gradle · GitHub
The apply false is simply ignored and actually it does not make any sense.
If you write apply false the intention is to add this plugin to the classpath of the script.
But with precompiled script plugins, you define the dependencies - including plugins you want to use - as dependencies in the build script of the project building the plugin, so the plugin already is in the classpath of that script.
Maybe a bit “out of topic” here now, but the name “convention plugin” associates for me something like a pattern, which makes it possible to provide a central bundle of plugins for our developers that guarantees that the plugins they apply (from this bundle) are compatible to the gradle version they use for the current project.
That doesn’t seem to work in this case, since most of the plugins we use in our project are only applied in (some) subprojects.
What do you think the appropriate pattern for this task?
Kind regards Tom
Not sure what you mean.
A convention plugin establishes your own conventions like plugins to apply and settings for those plugins.
So yes, “to provide a central bundle of plugins for our developers that guarantees that the plugins they apply (from this bundle) are compatible to the gradle version they use for the current project” should be covered by that.
But I don’t know what you mean with “That doesn’t seem to work in this case, since most of the plugins we use in our project are only applied in (some) subprojects.”.
The convention plugin still defines the plugin version to use.
Just not inline in the precompiled script plugin, but in the declared dependencies of your precompiled script plugin that you define in the build script of the project building the convention plugins, not in the project applying the convention plugins.
Whether you apply the convention plugin in a root project or subproject does not matter for that.
You apply a convention plugin to the project where those convention should be applied, so you might for example have a (sub)project that builds a java library and you apply a convention plugin to it that in turn applies the java-library plugin and some other plugins you want applied in all Java library plugins and does configuration for it.