Issue a warning if the same plugin is double-applied to a project

Typically the plugin’s ‘apply()’ method does some setup on the project, and in many cases adds a new extension.

I spent some time chasing a problem, where a plugin was applied twice to the same project and the second application clobbered all the settings done to the extension of the first one. I am not sure if there is a valid case to allow this, but in any case, a log message would have been useful.

It’s completely normal that a plugin gets applied multiple times to a project (because plugins build on top of each other), and Gradle makes sure that each plugin’s ‘apply’ method is only invoked once. There must be something else going on in your case.

I’ve come across similar issue while using finalizedBy on a task which has a GradleBuild type. My plugin was instantiated twice which was causing issues. Any points about that? How lifecycle of plugin relates to a task type GradleBuild?