How to set variable depending on current buildType, I have tried this
String url = "https://dev.myurl.com"
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig' || task.name == 'generateDebugBuildConfig') {
if (task.name == 'generateReleaseBuildConfig') {
url = "https://prod.myurl.com"
}
}
}
But no matter if the current buildType is Release or Debug, the tasks generateReleaseBuildConfig
and generateDebugBuildConfig
are both executed, so I never get the value depending on the current buildType. I specify that this variable is used later in build script and not in Java code.
I have tried several solutions found in SO but none worked for me