You forgot to add the properties file that tells Gradle about the mapping from plugin ID to implementation class. Have a look at the user guide about plugins.
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, then your custom plugin will need to be brought into your build script by 1 of 3 ways.
You can code it directly within your Gradle build script.
You can put it under buildSrc (ex. buildSrc/src/main/groovy/MyCustomPlugin).
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=desired.plugin.id into your newly created .properties file. Replace ‘desired.plugin.id’ with your desired plugin id.
See Custom Plugins by Gradle for more info.