Q:

How to correctly set Extra Properties within Gradle?

In my top level build.gradle project I am attempting to add extra properties using the following:
project.ext.libraries = [

        junit: 'junit:junit:4.10'

]

I then attempt to reference them in a lower level build.gradle but get this error:
testCompile([
                        project.libraries.junit
]) 

However I get this error:
"Could not find property "libraries" for project

Do I need to add anything else to my Gradle code to get this to work?

A:

Assuming that you have already setup the subproject relationship properly in root settings.gradle using include, in root level build.gradle
ext.libraries = [junit: 'junit:junit:4.10']

In your subproject:
dependencies{
  testCompile libraries.junit
}

All ext properties defined in your root project are available in the sub projects. 

