Aggregate gradle plugins


(David Ellis) #1

Is there a way that I can apply multiple plugins to a project by applying a single plugin that transitively applies other plugins, i.e. apply plugin: ‘mystandardsetofplugins’


(Benjamin Muschko) #2

David,

You can definitely do that in your plugin. Here’s an example that applies the WAR plugin. You can apply as many plugins as you want. The apply method works with a Class or String parameter.

class YourPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {
        project.getPlugins().apply(WarPlugin.class)
    }
}

(David Ellis) #3

awesome will try that thanks!


(Chris Cooper) #4

You can also do:

class YourPlugin implements Plugin<Project> {
    @Override
    void apply(Project project) {
        project.apply plugin: WarPlugin
    }
}