How to apply plugin to allprojects with new Gradle plugins mechanism?

The new plugins {...} syntax cannot be used within a allprojects {...} or subprojects {...} closure. Additionally, it can only be used within build scripts (no script plugins, init scripts, etc). If you want to avoid having to apply the plugin to each project individually I’d suggest using the old notation. This is an issue the Gradle team is aware of and a solution will be introduced in future versions.

Update: Starting with Gradle 3.0 you can do this in a slightly modified way. You still have to explicitly use apply() but you no longer have to deal with all the buildscript { } nonsense to get the plugin on your classpath. This also allows you to conditionally apply plugins. Check out the Gradle 3.0 release notes for more information.

plugins {
    id 'my.special.plugin' version '1.0' apply false
}

allprojects {
    apply plugin: 'java'
    apply plugin: 'my.special.plugin'
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)