Noel Yap
Noel Yap

Reputation: 19758

How to specify configuration order among Gradle sub-projects?

settings.gradle is:

rootProject.name = 'snth'

include 'snth-proto-definition'
include 'snth-server'
include 'snth-client-guice'

snth-server/build.gradle has:

sourceSets {
  main {
    java {
      srcDir "${project(':snth-proto-definition').protobuf.generatedFilesBaseDir}/server/java"
    }
  }
}

snth-client/build.gradle has:

sourceSets {
  main {
    java {
      srcDir "${project(':snth-proto-definition').protobuf.generatedFilesBaseDir}/client/java"
    }
  }
}

But while snth-server-guice/build.gradle gets processed fine, snth-client-guice/build.gradle errors with:

FAILURE: Build failed with an exception.

* Where:
Build file 'snth/snth-client-guice/build.gradle' line: 14

* What went wrong:
A problem occurred evaluating project ':snth-client-guice'.
> Could not find property 'protobuf' on project ':snth-proto-definition'.

How can I ensure that project(':snth-proto-definition').protobuf is defined before it's used?

Upvotes: 3

Views: 1325

Answers (1)

Noel Yap
Noel Yap

Reputation: 19758

Configuration time dependencies indicates use of evaluationDependsOn would allow finer-grained control of the configuration order of sub-modules. For example:

evaluationDependsOn(':snth-proto-definition')

Upvotes: 4

Related Questions