In our Gradle projects we recently migrated from defining our library versions in gradle.properties
to a version catalog using a libs.versions.toml
file.
We use a lot of scripting in some projects that rely on some of the versions in gradle.properties
.
In these scripts it was possible to override versions by passing command line arguments: gradlew task -PmyVersion=X
. This should also override versions defined in build.gradle:
dependencies {
implementation "com.example:your-library:${myVersion}"
}
However, the versions in libs.versions.toml
do not seem to change when passing version properties through a Gradle command, and the scripting does not behave as expected. I can change the build.gradle
file to read the version from libs.versions.toml
, but this will also ignore any properties passed through a Gradle command.
What is the best way to be able to override versions defined in libs.versions.toml
with command line arguments? Ideally, we would not like to modify all our existing scripts.