How can one reliably access another project's properties?

(Brian M. Carr) #1

I have a multi-module build, and occasionally need to access properties defined on one project from another (in inter-project dependencies). It seems that if the project containing the property is lexically sorted earlier, the property resolution works, but if it is later, it fails. I have linked a simple project which shows the problem.

when run:

$ gradle -Ptryc access
  Total time: 2.531 secs
$ gradle -Ptrya access
  FAILURE: Build failed with an exception.
  * Where:
Build file '/Users/bcarr/scm/multiprojectprops/childa/build.gradle' line: 3
  * What went wrong:
A problem occurred evaluating project ':childa'.
Cause: Could not find property 'exampleProperty' on project ':childb'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 2.131 secs

(Luke Daley) #2

Hi Brian,

This section of the userguide discusses evaluation time dependencies.

(Brian M. Carr) #3

To leave a more complete answer for anyone who finds this via search:

The build.gradle for the dependant projects can add


To include the parsing order such that childb has all of its properties before childa is parsed.