I am trying to add some extra properties (constants) to my build scripts.
I have defined dependencies.gradle for storing dependencies and constants.
// Project repositories
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
ext {
// Build Tools
gradleVerison = '2.2.3'
//Android
buildDependencies = [
gradle : "com.android.tools.build:gradle:${gradleVerison}",
]
}
And in my root build.gradle file I want to use defined ext properties like that
// Retrieve dependencies
apply from: 'buildsystem/dependencies.gradle'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath rootProject.ext.buildDependencies
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But it won’t work
Error:(9, 0) Cannot get property 'buildDependencies' on extra properties extension as it does not exist
I have tried different variants
def globalConfiguration = rootProject.extensions.getByName("ext")
globalConfiguration.getAt("buildDependencies")
project.ext.buildDependencies
project.buildDependencies
...
But still the same error. Please help to get it working. And please explain internals of this code. Thanks.