Ext from parent (non-root)


(surlac) #1

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 https://docs.gradle.org/current/userguide/multi_project_builds.html, couldn’t find answer.

How would I allow child modules to use Ext from non-root module? See sample project: http://www.mediafire.com/file/7e4sqc2g567apx8/ext-issue.zip