Default value for a $PROPERTY in Gradle
if (!project.hasProperty("build_version")) {
ext.build_version = "1.0"
}
This worked for me:
def AWS_ACCESS_KEY="nokey"
def AWS_SECRET_KEY="nokey"
if (project.hasProperty("AWS_ACCESS_KEY")) {
AWS_ACCESS_KEY=project.get("AWS_ACCESS_KEY")
}
if (project.hasProperty("AWS_SECRET_KEY")) {
AWS_SECRET_KEY=project.get("AWS_SECRET_KEY")
}
This checks if the property exists and assigns a default value if not:
def build_version=project.properties['build_version'] ?: "nokey"