Actually I had this question for a long time. Let me explain.
For example, I have a multiple sub-projects project. And I like to configure every sub-project in the root project’s build config, instead of copy the configuration every time, which looks pretty reasonable. Now, I want to configure sonar
plugin, only for sub-projects, and configure it. But when I use apply false
after the id
statement, here comes the problem. The sonarqube
block will throws exception, the gradle thinks there are no such function.
So I can not diable applying for plugin, if I want to configure it. I am kind of understanding this. When gradle run configuration under root project, it will only using the plugin that applied to root
. Even I used apply(plugin="sonar")
, it will not found the plugin, since the configuration is already running.
And I do know, I can use task<T>
to configure the task that I want, without accutally applying it. But there are some plugins, which’s extension not fully equals to their task’s paramter. Because I have already write such one for our group.