Add new buildscipt classpath dependencies in a plugin

plugins

(Marcin Zajączkowski) #1

I would like to simplify the way how a group of other plugins are applied and configured - the meta-plugin would take care of adding required dependencies, applying plugins and providing default configuration. However, I have problem with adding additional dependencies (to the other plugins) on my plugin apply:

InvalidUserDataException: Cannot change dependencies of configuration
    ':classpath' after it has been resolved

Applying gradle files with apply from: before my plugin apply is problematic - those file would be required to get from a jar (e.g. with ant.unjar), some logic would need to be duplicated.

Is there any workaround to allow to add new plugins by the another plugin (on its apply)?


(Stefan Oehme) #2

The plugin should depend on the other plugins, not try to modify the buildscript.classpath of the project. So in your plugin project, just add a compile dependency on the other plugins and they will be pulled in too.


(Marcin Zajączkowski) #3

Thanks. It sounds very sensible and straightforward :).

Probably I was just fixed with adding dependencies at runtime as in one of my plugins I do it using another buildscript configuration to pass to the underlying process which is executed without having that dependency visible as a classpath dependency in the projects using my plugin.