I've found this to be the easiest and cleanest way, without requiring a gradle.properties
file or changing the version
variable name.
In build.gradle
:
// Note - there is intentionally no equals sign hereversion project.hasProperty('version') ? version : '1.0.0'
From the command line:
./gradlew -Pversion=1.5.2 build