How do I use a plugin defined in a sub-project in one of my other sub-projects?

I’m looking to refactor the Lazybones project into a 3-sub-project build with:

  • lazybones-gradle-plugin * lazybones-templates * lazybones-app

The Lazybones Gradle plugin is designed to simplify the packaging and publication of templates and I want to use it in the lazybones-templates project. Unfortunately, the lazybones-templates build complains that it doesn’t know about the Gradle plugin.

This is the extent of the lazybones-templates build file:

buildscript {
    repositories {
        maven {
            name "local"
            url = "file://${rootProject.buildDir}/sharedRepo"
      dependencies {
        classpath "" //project(":lazybones-gradle-plugin")
  apply plugin: "lazybones-templates"

I originally had a ‘project()’ reference in the ‘buildscript’, but that didn’t seem to work either.

Is it possible to define a plugin in the same multi-project build as it’s used?

With Gradle’s strict separation of configuration and execution phase, this is a catch-22. There are some ugly workarounds such as pointing ‘buildSrc’ at the same plugin sources or running the plugin in a forked build (with a ‘GradleBuild’ task), but I can’t say if they’ll work for you. If feasible, consider using an older published version of the plugin instead.

Thanks Peter. I think I’ll start with a copy of the plugin in buildSrc of lazybones-templates until an initial version of the plugin is published. That will also make it easier to test and debug the plugin in these early stages.

PS I can’t see how to mark this question as answered :frowning: