I would like to grab a parameter from gradle command line -Pfruit=Apple
And then put this parameter into a BuildConfig
for every buildType
.
I'm trying to achieve using:
buildConfigField("String", "env", "\"${project.fruit}\"")
Unfortunately I don't know how to set default value like "Pear"
there, and how to set it for all build types.
Try this :
buildConfigField("String", "env", project.hasProperty('fruit') ? '"' + project.fruit + '"' : '"Pear"')