How to easily test your custom plugin in another Gradle project?

Hi all,

I’m working on my first Gradle plug-in to add a code quality tool to my other Gradle projects. When I’m done testing it I intend to publish it on GitHub and BinTray, but I would really like to test it on some of my local projects first.

I’ve added the following to the top of build.gradle of an Android app:

buildscript {
    repositories {
        flatDir {
            dirs '/path/to/my/custom/plugin/project/build/libs'
        }
    }
      dependencies {
        classpath name: 'NameOfTheGeneratedJarWIthoutTheExtension'
    }
}
  apply plugin: 'com.android.application'
apply plugin: 'qualified.plugin.name'

Although it does find the JAR dependency, it states that the plugin was not found. Is there an easy way to fix this? Or does anyone know of a better / easier way to quickly add a local plugin project to an existing project in order to do some “real-life” tests?

Thanks in advance,

Kind regards, Arno

1 Like

No need to define a repository, just use a file dependency.

dependencies {

classpath files(‘path/to/plugin.jar’)

}

Thanks for the suggestion. Unfortunately I’ve already tried that, without success.

buildscript {
    dependencies {
        classpath files('/Volumes/Storage/Development/Gradle/Plugins/PyLizardPlugin/build/libs/PyLizardPlugin-0.1.jar')
    }
}
  apply plugin: 'com.android.application'
apply plugin: 'amnl.pylizard'

Error is as follows:

Plugin with id 'amnl.pylizard' not found.

PS: I have the correct META-INF/amnl.pylizard.properties resource in my plugin project.

That is your problem. It should be ‘META-INF/gradle-plugins/amnl.pylizard.properties’.

Similar story, same question: I can apply my own plugin using its fully qualified classname, but only using (‘META-INF/gradle-plugins/.properties’ is present) does not work. By looking at the code involved with loading plugins in Gradle, it seems that there is not much logging involved in this area, making it very hard to determine why it is failing…

If anybody is interested, my plugin(s) can be found here for review…

Thanks! That’s exactly why it wasn’t working.