I created a simple Kotlin Gradle plugin (using the standalone project Gradle plugin documentation). I cannot find the correct steps to load the fat jar locally into my test project instead of from a repository. I tried
and every scenario ends up with the following message:
Plugin [id: 'myplugin', version: '1.0'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'myplugin:myplugin.gradle.plugin:1.0')
Searched in the following repositories:
Gradle Central Plugin Repository
BintrayJCenter
flatDir(/path/to/plugin/dir)
Apologies. Do you want to apply the custom plugin you created? And exercise it in your „test project“?
Or do you only want to access the actual Jar file that the publish task generated? And do something with the actual Jar file that contains your custom plugin?
No worries. It was my mistake. I appreciate your time.
I was looking to load the gradle plugin that I made into my other project, but without publishing it to the Gradle Plugin Portal. Unless I’m wrong here and publishing it to the portal is the only way to add it to my project. So if my gradle plugin adds a task fancyNewTask, I want to add it to project foo and run the new fancyNewTask in that project.
As an aside: This zip file contains an example of a custom plugin project that has the pluginManagement{} block in settings.gradle. I prefer that over Gradle’s stock example because it keeps the build.gradle script simpler in my opinion.
The stock Gradle sample project I linked to above is a multi-module-type structure. It has one project folder for the plugin and a second project for the user of the plugin.
The directory structure in my attached custom plugin project, on the other hand, is flat. There’s only a single project. I prefer this simpler structure for doing quick and dirty experiments and proofs of concept.
But there are two build scripts in my example. One to build and install the custom plugin. And a second script that consumes the plugin.
To consume the plugin, I pass Gradle the name of the consumer build script explicitly: gradle --build-file=use.plugin.gradle myTask.