Custom Gradle Plugin ID not found

gradle custom plugin
gradle core plugins (plugin is not in 'org.gradle' namespace)
gradle plugin was not found in any of the following sources
plugin with id not found
gradle plugin dependencies
java-gradle-plugin
write gradle plugin in kotlin
gradle local plugin

I'm writing a Gradle plugin and I'm failing to get the apply plugin: command to work in the Gradle script that uses the plugin. I'm using Gradle 1.1.

I've build the plugin with clean build and I'm attempting to add it to the Gradle build via a flat repo for now. That seems to be working but Gradle isn't picking up that there is a plugin with the ID test-plugin. The project name in the plugin's settings.gradle is test-plugin and the properties file in META-INF/gradle-plugins is also test-plugin.properties. I'm not sure where else I can specify the plugin ID.

The build.gradle file in the project that is using the test-plugin:

repositories {
  flatDir name: 'libs', dirs: "../build/libs"
}

dependencies {
  compile 'test:test-plugin:0.1'
}

apply plugin: 'test-plugin'

Error from Gradle:

What went wrong:
A problem occurred evaluating root project 'tmp'.
Plugin with id 'test-plugin' not found.

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"

Using Gradle Plugins, Plugin with id 'com.bmuschko.tomcat' not found. Context. This is an unnecessary limitation of Gradle's plugin system. Users run into the issue all  Known issues with the Android Gradle Plugin. Configuration on demand with Gradle 4.6 and above: If you're using Android Gradle Plugin 3.0.x or 3.1.x with Gradle 4.6 and above, you should disable configuration on demand to avoid some unpredictable build errors. (If you are using Android Gradle Plugin 3.2.0 or higher, you do not need to take any

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=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.

Developing Custom Gradle Plugins, 'java' is the short plugin id for the class org.gradle.api.plugins.JavaPlugin . We can define a short plugin id for our own custom plugins as well, Gradle Goodness: Add But Do Not Apply Plugin Using Plugins Block (Matching score 38​%) Gradle Goodness: Using and Working with Gradle Version · Gradle  How To Fix The one signal-grade-plugin MUST be before com.android.application! How To Solve The onesignal-gradle-plugin MUST be before com.android.application! Warning. Remove Gradle Warning: The

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.

Third-party plugins cannot be applied by ID from external build , To create a custom standalone Gradle plug-in using java (you can also use Groovy) you If settings.gradle file is not present in the plugin directory the default value will be the name Notice that the properties filename matches the plugin id. My project runs with no issues on the old versions but when runs on Java 11 and Gradle 6 it complains about fireBugs plugin and raises the following exception: > Plugin with id 'findbugs' not found. Snippet of gradle file: buildscript { ext { SampleProjectVersion = '1.3.4' } repositories { mavenLocal() maven { url1 } } dependencies { classpath(sample lib 1) classpath(sample lib 2) } apply plugin: 'findbugs'

Gradle Goodness: Define A Short Plugin Id For Custom Plugins , A quick and practical example of writing a custom Gradle plugin. We can simply put the source code of our plugin inside the build script itself. So if our plugin has an id of org.baeldung.greeting, the exact path of the file would be projects to Gradle repository can be found in Gradle Plugin Portal Documentation​. When we're writing our plugins in Java, we can benefit from the Java Gradle Development Plugin. This will automatically compile and add gradleApi() dependencies. It will also perform plugin metadata validation as a part of the gradle jar task. We can add plugin by adding following block to our build script: plugins { id 'java-gradle-plugin' } 6.

gradle, A practical guide to writing, testing and publishing custom Gradle plugins Unfortunately, I found the documentation and examples on writing a custom Gradle The id , is the identifier of your plugin, which is used to apply it your plugin: I'll not dive into unit testing the Gradle plugin, as it's no different from  Most plugins offer some configuration options for build scripts and other plugins to use to customize how the plugin works. Plugins do this using extension objects.The Gradle Project has an associated ExtensionContainer object that contains all the settings and properties for the plugins that have been applied to the project.

Writing Custom Gradle Plugins, Gradle - Plugins - Plugin is nothing but set of tasks, almost all useful tasks such as it and some Community plugins are using fully qualified name for plugin id. While creating a custom plugin, you need to write an implementation of plugin. Plugins; Documentation . How do I add my plugin to the plugin portal? How do I use the “plugin-publish” plugin? How do I link an existing plugin to my account? How do I delete my plugin from the portal? How do I mirror the plugin portal? How do I get further help? Forums

How to write, test and publish a custom Gradle plugin, This version of Gradle uses com.gradle.build-scan as the plugin ID. If the location of a Gradle Enterprise server is not specified, build scans will be The examples you have seen so far work well if when the custom data is available at the  Expected Behavior. As an Artifactory maintainer I want my artifactory instance to be able to serve all of the plugins on the Gradle Plugins Portal to my internal network in a way which is compatible with the new plugins syntax so that I can easily resolve all of the plugins for my builds using this clearly superior new style of specifying all my plugins.

Comments
  • how do you add multiple plugins?
  • Add each plugin's classpath in the dependencies block, and have an apply-plugin: "your-plugin" line for each.
  • apply plugin: YourCustomPluginClassName seems to be a kind of deprecated way to use a plugin (2019).
  • apply plugin: is in many examples on the Gradle tutorial for writing custom plugins