Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Gradle Plugin ID not found

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. 
like image 657
Patrick Auld Avatar asked Sep 24 '12 17:09

Patrick Auld


People also ask

What is Gradle plugin ID?

You apply plugins by their plugin id, which is a globally unique identifier, or name, for plugins. Core Gradle plugins are special in that they provide short names, such as 'java' for the core JavaPlugin. All other binary plugins must use the fully qualified form of the plugin id (e.g. com. github. foo.

What is Gradle buildScript block?

The buildScript block determines which plugins, task classes, and other classes are available for use in the rest of the build script. Without a buildScript block, you can use everything that ships with Gradle out-of-the-box.


1 Answers

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" 
like image 189
Peter Niederwieser Avatar answered Sep 28 '22 14:09

Peter Niederwieser