Custom Gradle Plugin ID not found

If you want to implement a plugin into your buildscript, then you have two options.

Option 1
apply plugin: YourCustomPluginClassName

Option 2

plugins {
    id 'your.custom.plugin.id'
}

apply plugin: is used when specifying your plugin by its class name (ex. apply plugin: JavaPlugin)
plugins { } is used when specifying your plugin by its id (ex. plugins { id 'java' })
See Gradle Plugins by tutorialspoint for reference

If you choose Option 1, the your custom plugin will need to be brought into your build script by 1 of 3 ways.

  1. You can code it directly within your Gradle build script.
  2. You can put it under buildSrc (ex. buildSrc/src/main/groovy/MyCustomPlugin).
  3. You can import your custom plugin as a jar in your buildscript method.
    See Gradle Goodness by Mr. Haki for information about the buildscript method.

If you choose Option 2, then you need to create a plugin id. Create the following file buildSrc/src/main/resources/META-INF/gradle-plugins/[desired.plugin.id].properties.

Copy and paste implementation-class=package.namespace.YourCustomPluginClassName into your newly created .properties file. Replace package.namespace.YourCustomPluginClassName with the fully-qualified class name of your desired plugin class.

See Custom Plugins by Gradle for more info.


I also had the same problem with a custom plugin id not being found. In my case, I simply forgot to add the 'src/main/resources/META-INF/gradle-plugins' properties file. The name of the properties file must match the name of the plugin id with a '.properties' extension.

The file must contain a the line:

implementation-class=(your fully qualified plugin classpath)

That's the complete mechanism on how plugin id's get resolved to class names.

In addition the plugin needs to be added as a dependency as pointed out in the previous answer. The android documentation states that you should use a name associated with your unique domain name. I.e.: the name 'test-plugin' is not really in good form, but an id like 'com.foo.gradle.test-plugin' would be better.


The plugin Jar has to be added as a build script dependency:

buildscript {
    repositories { flatDir name: 'libs', dirs: "../build/libs" }
    dependencies { classpath 'test:test-plugin:0.1' }
}

apply plugin: "test-plugin"