Loading local Kotlin Gradle plugin

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

// build.gradle.kts
buildscript {
    dependencies {

and I tried variations of

// settings.gradle.kts
pluginManagement {
    repositories {
        flatDir {

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

You want the „Automatic injection with the Java Gradle Plugin Development plugin“ section of the user guide.

Here’s the associated code.

This looks like a runner for testing the gradle pluign, which I have done and that works. Maybe I confused things by saying “test project”.

I’m wanting to load the Gradle plugin jar into a real project, but located locally on my computer.

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?

Rereading your reply more carefully, it sounds like you probably want this example instead.

1 Like

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.

Yeah, we both hit send at the same time :slight_smile:

That customPlugin example I posted above is the template I follow when I want to do what you described.

I got it working! Thanks. I used that example before. It looks like I mistakenly forgot:

In Gradle plugin project:

  • Add maven-publish

  • Add publishing block in build.gradle.kts

    publishing {
    repositories {
    maven {
    url = uri("$buildDir/repo")

In my project that consumes/uses the plugin:

  • Add maven url block in buildscript block into build.gradle.kts

    buildscript {
    repositories {
    maven {
    // end::use-task
    // end::use-plugin
    val producerName = findProperty(“producerName”) ?: “plugin”
    val repoLocation = “…/$producerName/build/repo”
    // tag::use-plugin
    // tag::use-task
    url = uri(repoLocation)
    dependencies {

  • Apply plugin:

apply(plugin = "org.samples.greeting")

Thanks again!

You bet :+1:

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.

Awesome! Thanks for the tip and guidance.