Ext from parent (non-root)

Library consists of 2 modules. Root-level build.gradle has Ext variables defined, which used in module-1 and module-2 (to keep dependencies in one place).

my-lib
|-- module-1
| ±- build.gradle
±- module-2
| ±- build.gradle
|-- build.gradle (ext here)
±-settings.gradle

When library included in client project, it looks like following:

client
|-- module-3
| ±- build.gradle
±- my-lib (included)
| |-- module-1
| | ±- build.gradle
| |-- module-2
| | ±- build.gradle
| |-- build.gradle (ext here)
| ±- settings.gradle
|-- build.gradle
±-settings.gradle

The problem is project doesn’t build, since Ext variable defined in module-2 is not accessible.

  • What went wrong:
    A problem occurred evaluating project ‘:module-2’.
    Cannot get property ‘key1’ on extra properties extension as it does not exist

I read Structuring and Building a Software Component with Gradle, couldn’t find answer.

How would I allow child modules to use Ext from non-root module? See sample project: ext-issue