gradle.star¶
Bump Gradle dependencies, version catalog entries and the Gradle wrapper.
Edits are line-based, so comments and formatting in build scripts and libs.versions.toml stay as they were.
load("@fleet//gradle.star", "build_files", "set_dependency", "wrapper_version", "set_wrapper_version", "set_plugin", "set_kotlin_version")
| Function | What it does |
|---|---|
build_files |
Lists the build scripts and version catalogs. |
set_dependency |
Sets a library's version wherever the build declares it. |
wrapper_version |
Reads the Gradle version the wrapper downloads. |
set_wrapper_version |
Points the Gradle wrapper at a new version, never lowering it. |
set_plugin |
Sets the version of a Gradle plugin wherever the build applies or declares it. |
set_kotlin_version |
Moves every Kotlin Gradle plugin, and the Kotlin standard library, to one version. |
build_files¶
Lists the build scripts and version catalogs.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The sorted paths of every build.gradle, build.gradle.kts, settings.gradle(.kts) and *.versions.toml outside build directories.
Example
set_dependency¶
Sets a library's version wherever the build declares it.
A newer version already there is kept, so a campaign never lowers one.
Covers string coordinates in build scripts ("group:name:1.0", in
Groovy or Kotlin), and in version catalogs both alias = "group:name:1.0"
and { module = "group:name", version = "1.0" }, including a
version.ref that points into [versions]. Coordinates whose version is
a variable ("group:name:$v") are left alone.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
module |
The library as group:name. |
version |
The new version. |
Returns: The list of paths that changed.
Example
set_dependency(repo, "com.squareup.okhttp3:okhttp", "4.12.0")
set_dependency(repo, "com.fasterxml.jackson.core:jackson-databind", "2.17.2")
# returns ["gradle/libs.versions.toml"]
Used in: jvm-dependency-bump
wrapper_version¶
Reads the Gradle version the wrapper downloads.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The version, such as 8.5, or None when the repo has no wrapper.
Example
set_wrapper_version¶
Points the Gradle wrapper at a new version, never lowering it.
Only gradle-wrapper.properties changes; Gradle downloads the new
distribution on the next run. When the file pins a checksum with
distributionSha256Sum, pass the new distribution's sha256 from
https://gradle.org/release-checksums/, or the run fails rather than
leave a checksum that no longer matches.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The Gradle version, such as 8.10.2. |
sha256 |
The SHA-256 of the new distribution zip, for wrappers that verify it, or a dict of it by distribution type (bin, all), so one campaign covers both. |
Returns: True when the file changed.
Example
gradle/wrapper/gradle-wrapper.properties
Used in: gradle-wrapper-bump
set_plugin¶
Sets the version of a Gradle plugin wherever the build applies or declares it.
A newer version already there is kept, so a campaign never lowers one.
Covers id 'x' version 'v' (Groovy), id("x") version "v" (Kotlin), and
version catalog [plugins] entries, written as { id = "x", version = "v" },
{ id = "x", version.ref = "key" } (setting [versions] instead) or
"x:v". For Kotlin plugins, kotlin("jvm") version "v" matches
org.jetbrains.kotlin.jvm.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
plugin |
The plugin ID, such as com.android.application. |
version |
The new version. |
Returns: The list of paths that changed.
Example
set_plugin(repo, "org.jetbrains.kotlin.android", "2.0.21")
set_plugin(repo, "com.android.application", "8.7.2")
# returns ["build.gradle.kts", "gradle/libs.versions.toml"]
set_kotlin_version¶
Moves every Kotlin Gradle plugin, and the Kotlin standard library, to one version.
A newer version already there is kept, so a campaign never lowers one.
Sets every org.jetbrains.kotlin.* plugin a build applies (in either
DSL or a version catalog), the kotlin-gradle-plugin classpath
dependency of older builds, a kotlin or kotlin_version entry in
[versions], and ext.kotlin_version in Groovy builds.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
version |
The Kotlin version, such as 2.0.21. |
Returns: The list of paths that changed.
Example