how do you test a gradle plugin locally?
The page on 'how to test your plugin' glosses over how to configure 'apply plugin' to pull from maven local. How do you use your plugin that you've published to mavenLocal?
This should be flushed out more, but to answer your question: Don't publish to maven local, just use a composite build.
Assuming this sort of structure:
my-plugin/
gradlew
gradle/...
build.gradle
settings.gradle
my-plugin-consumer/
gradlew
gradle/...
build.gradle
settings.gradle
In my-plugin-consumer, you can do ./gradlew --include-build ../my-plugin ... to include "my-plugin" as part of the composite build and Gradle will automatically build my-plugin if my-plugin-consumer applies the plugin. You need to use the plugins {} block to apply the plugin for this to work.
I had the same issue, but you can add a build script to load the jar from the filesystem.
First I generate a Jar for the custom plugin then add the Jar to a test project to test the plugin.
I manually create a build/libs folder in test project and copy Jar to it, I then add the following at the top of build.gradle file of test project:
buildscript { repositories { flatDir name: 'libs', dirs: "./build/libs" } dependencies { classpath 'custom-plugin:custom-plugin:1.0' } }
And then use apply plugin: plugin-id
I have an example of doing some of this here: https://github.com/JLLeitschuh/ktlint-gradle
This issue is pervasive in the plugin docs.
https://docs.gradle.org/current/userguide/custom_plugins.html starts by referring to the plugin's build.gradle file, and then in later examples is showing source for a hypothetical plugin consumer's build.gradle. But there is no mention of how that consumer was configured to consume the plugin that is being developed in the walkthrough.
The 'Testing Gradle Plugins' walkthrough is so terse with regard to project setup as to be just wrong (https://guides.gradle.org/testing-gradle-plugins/). Clearly this page needs a basic git project example to back it up.
Many of the examples are using 'apply plugin' instead of the plugins block. If it's necessary, it needs explanation, and if it's not necessary, shouldn't the examples use the plugins block instead?
The closest thing I've found to a working explanation is in the 'Using your plugin in another project' section of https://docs.gradle.org/current/userguide/custom_plugins.html, which let me do a publishToMavenLocal and consume it in any other arbitrary project ( after adding mavenLocal() to the settings.gradle pluginManagement block )