fleetlint Policy for a fleet of repositories
v0.8
Getting started

repo/toolchain-pinned/kotlin

Toolchain version is pinned

Implements repo/toolchain-pinned for kotlin.

Severitywarning
Tiers1, 2
Stackskotlin
Scopeeach
Kindexpr
Sourcelibrary v0.5.0
Selected byfleetlint-recommended@v0.5.0

Requirement

The JDK is pinned: a Gradle toolchain in the project’s or a parent build (jvmToolchain(n), JavaLanguageVersion.of(n)), gradle-daemon-jvm.properties, .java-version, .sdkmanrc with java=, or .tool-versions/mise naming java. The Gradle wrapper pins Gradle, not the JDK; the Kotlin version is pinned by the plugin version already.

Why

Without a pin, every machine and every CI run builds with whatever compiler or runtime happens to be installed, and failures cannot be reproduced.

Check

["", "../", "../../", "../../../"].exists(d, file(d + ".java-version") && scan(d + ".java-version", r'^\s*\S*\d').size() > 0) || ["", "../", "../../", "../../../"].exists(d, file(d + ".sdkmanrc") && scan(d + ".sdkmanrc", r'^\s*java\s*=\s*\d').size() > 0) || ["", "../", "../../", "../../../"].exists(d, file(d + "gradle/gradle-daemon-jvm.properties") && text(d + "gradle/gradle-daemon-jvm.properties").matches(r'toolchainVersion\s*=\s*\d')) || (glob("**/build.gradle*") + ["../", "../../", "../../../"].map(d, [d + "build.gradle", d + "build.gradle.kts"]).flatten().filter(f, file(f)))
     .exists(f, text(f).matches(r'languageVersion(\.set\(|\s*=\s*)\s*JavaLanguageVersion\.of\(\s*\d|jvmToolchain\s*\(\s*\d'))
|| ["", "../", "../../", "../../../"].exists(d, file(d + ".tool-versions") && scan(d + ".tool-versions", r'^\s*(java)\s+\S*\d').size() > 0) || ["", "../", "../../", "../../../"].exists(d, ["mise.toml", ".mise.toml", ".config/mise.toml", ".config/mise/config.toml", "mise/config.toml"].exists(n,
     file(d + n) && scan(d + n, r'^\s*"?(java)"?\s*=\s*[^#\n]*\d').size() > 0))

Fix

Add kotlin { jvmToolchain(21) } to the build.

Agent instruction: Add the stack’s toolchain pin set to the version currently installed; do not upgrade the toolchain in the same change.

A finding of this rule points at the file (["build.gradle.kts", "build.gradle"].filter(f, file(f)) + ["build.gradle.kts"])[0] yields.

Sources


Generated by fleetlint docs from catalog v0.5.0.