I want to access the defaultConfig which define in a subproject (app--> build.gradle) into a parent build.gradle but seems to be not working OR I am doing something wrong. Actually I need to access the buildvarient which I define in a defaultConfig of app build.gralde file.
app build.gradle:
android {
def buildTypeV // define here to update in loop
dependencies.metaClass.allCompile { dependency ->
buildTypes.each { buildType ->
// "${buildType.name}Compile" project(path: ":${dependency.name}", configuration: buildType.name)
buildTypeV=buildType.name
}
}
defaultConfig {
versionNameSuffix "${buildTypeV}"
}
From parent build.gradle file, I am doing like this to access versionNameSuffix:
gradle.buildFinished {
def buildV=${project.android.defaultConfig.versionNameSuffix};
println "buildV:::: $buildV"
}
It seems to be a wrong way to access the defaultConfig as the build is failing it. Can someone give me an idea of how I can access It properly?
Error which I see on console:
* What went wrong:
Could not find method $() for arguments [build_8kbbn8x9zcumz6eqfx8ryt61s$_run_closure2$_closure3@77596dd9] on root project 'df-backpack' of type org.gradle.api.Project.
In my subproject define application variant:
android.applicationVariants.all { variant ->
variant.outputs.all {
def flavor = variant.name
outputFileName = "../app-${flavor}-final.apk"
}
variant.assembleProvider.get().doLast getbuilder(variant.name.toLowerCase())
}
// in parent build.gradle:
project('hpnurse') {
buildStr=it. android.applicationVariants.all;
//also tried like this
//it.variant.buildType.name;
}