How do I make my buildscript depend on a custom task library of another module in a multi-module project?

Is it possible to make a project’s buildscript dependent on a task library in a multi-module project? The documentation show some examples of external dependencies, but I didn’t find any hint on using dependencies inside a multi-module project.

Based on the customPlugin sample from the gradle sources you can find a demo of my problem here:

When executing ‘./gradlew’ I get an error message like this:

FAILURE: Build failed with an exception.

  • Where:

Build file ‘/home/gesellix/workspace/gradleCustomPlugin/build.gradle’ line: 14

  • What went wrong:

A problem occurred evaluating root project ‘gradleCustomPlugin’.

Could not find property ‘org’ on root project ‘gradleCustomPlugin’.

I would expect that Gradle evaluated the “:plugin” submodule before the parent project and that the plugin’s task classes would be available in the parent project. I would also expect that I wouldn’t have to apply the “plugin”, because I only need the GreetingTask in the buildscript’s classpath.

Is this possible with Gradle or do I have to build the plugin module uncoupled from the parent project?

Thanks for your help!

Currently gradle does not support a project dependency in the buildscript classpath as in

buildscript {
  repositories {
    maven {
      url uri('../repo')
  dependencies {
    classpath project(':plugin')

The reason is, that :plugin cannot be evaluated before the classpath is configured. So it’s some kind of chicken-egg problem. All stuff in buildscript{} is evaluated before any other build script logic is evaluated.

We have a story to fix this in our design-docs:


There might be a workaround by adding ‘buildSrc’ manually as a ‘normal’ subproject via settings.gradle, but I havn’t thought about that in detail.

cheers, René

So I guess I should clean the chicken house to fix the chicken-egg problem :slight_smile:

Since you already have a story in your design-docs I would tag this thread as answered for the time being. Do I have to close this thread somehow?