Reputation: 7394
I am trying to declare the dependencies
in my gradle project using the technique described in this answer.
However when I do so I get this error:
No such property: libraries for class
How can I fix this?
Dependencies declared as properties at top level build.gradle as follows:
ext.libraries = [
junit: 'junit:junit:4.10'
]
Trying to retrieve dependency in module level build.gradle (where error is being thrown):
testCompile([
libraries.junit
])
Error thrown:
No such property: libraries for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
Upvotes: 5
Views: 4003
Reputation: 23737
In your top level settings.gradle
, include your subproject:
include 'subproject'
In your top level build.gradle
define your ext properties:
ext.libraries = [junit: 'junit:junit:4.10']
it does not have to be a map, if you're using just 1 value, but I'm sticking with your formatting.
To use this in your subproject build.gradle
:
dependencies{
testCompile libraries.junit
}
Upvotes: 3