refreshVersions centralizes dependency versions in a versions.properties file (Java Properties format) instead of using Groovy or Kotlin code. This makes the version file machine-readable and easy to manipulate with tooling.
The Opt-in Mechanism
To allow refreshVersions to manage a dependency, you must use an underscore _ as a placeholder for the version in your build.gradle[.kts] files. This tells the plugin that the version is not hardcoded but is instead managed via the versions.properties file.
Version Key Mapping
By default, the plugin maps dependency notations to version keys. You can use a system of rules to group multiple artifacts under a single version key to keep your configuration DRY (Don't Repeat Yourself).
| Dependency notation | Version key example |
|---|
org.gradle:gradle-hello-world-plugin:_ | version.org.gradle..gradle-hello-world-plugin |
com.squareup.retrofit2:retrofit:_ | version.retrofit |
com.squareup.retrofit2:retrofit-adapter-xxx:_ | version.retrofit |
plugin with id com.squareup.sqldelight | plugin.com.squareup.sqldelight |