Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / kotlin

Kotlin version is pinned

kotlin/kotlin-version-pinned@v1

The Kotlin compiler version is declared in the build, and is no older than the configured floor.

Idkotlin/kotlin-version-pinned
Versionv1
Categorykotlin
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectskotlin

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
kotlinThe Kotlin version the Gradle or Maven build declares and the file that declares it, for the project and for every Gradle project it includes.projectDir

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "kotlin/kotlin-version-pinned@v1",
              "severity": "warning",
              "with": {
                  "projectDir": ".",
                  "minVersion": "1.8"
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR
minVersionOldest Kotlin version accepted. A pinned version below this is a violation.1.8GUARDRAIL_INPUT_MINVERSION

How to fix

Declare the compiler version where the build applies the Kotlin plugin, for example kotlin("jvm") version "2.4.0" in build.gradle.kts, a kotlin entry under [versions] in gradle/libs.versions.toml, or <kotlin.version> in pom.xml. Without it the compiler drifts between a laptop and CI.

More in kotlin

  • kotlin/build-manifest. The project declares a recognised build manifest, so the build is reproducible and tooling can find it.
  • kotlin/dependencies-locked. The Gradle build commits the lock files that resolve its dependencies, so the same commit builds from the same versions.
  • kotlin/gradle-wrapper. A Gradle project commits gradlew and the wrapper properties that pin the Gradle version.

All 4 kotlin guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412