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

Guardrails / Collectors

Kotlin build

The Kotlin version the Gradle or Maven build declares and the file that declares it, for the project and for every Gradle project it includes.

Facts keykotlin
Versionv1
Scriptkotlin.py
Timeout30 seconds
Collects fromgradle, maven

Collectors

kotlin doesn't read the build itself. It derives its facts from the collectors below. The CLI runs those first, passes their results to kotlin, then hands the guardrail the facts it asked for.

CollectorGathers
gradleThe Gradle build in the project directory: its settings and manifest, every included project, the wrapper and the distribution it pins, the version catalog, and every dependency the build files declare or the lock files resolve, with the versions its platforms supply.
mavenThe Maven build in the project directory: the root pom.xml coordinates, its modules, its properties and every dependency it and its modules declare, with the versions its imported BOMs supply.

Inputs

InputDescriptionDefaultEnvironment
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR

A guardrail that declares an input of the same name passes it through, so the guardrail's configuration in buildnote.json is what decides these values.

A guardrail asks for these facts by name, and reads them back the same way:

json
{
  "collect": ["kotlin"]
}
python
kotlin = guardrail.facts("kotlin")

Facts

The document kotlin collects. A path carrying [] is an entry of the list before it, and one carrying [path] is a key of the object before it.

FactMeaning
directoryThe projectDir input, as the guardrail configured it.
existsWhether the Gradle or Maven build reports that directory is there. Nothing else is collected when it is not, and the collector collects nothing at all when neither of them collected anything.
sourcesThe Gradle and Maven build files that were there to read, Gradle first.
declaredWhere the Kotlin version is declared, or null when nothing declares one. A Gradle manifest wins over the version catalog, and Gradle wins over Maven.
declared.versionThe version declared.
declared.sourceThe file declaring it.
projectsThe root project followed by every project the Gradle settings file includes.
projects[].pathGradle path of the project, : for the root.
projects[].directoryDirectory holding it, relative to projectDir.
projects[].declaredWhere that project declares its own Kotlin version, shaped as above, or null.

A collector that cannot finish prints what it had along with an incomplete key saying why, so the facts below the point it stopped are absent. A check that cares reads incomplete before the rest.

Example facts

The example facts collected by kotlin collector:

json
{
  "directory": ".",
  "exists": true,
  "sources": [
    "build.gradle.kts",
    "gradle/libs.versions.toml"
  ],
  "declared": {
    "version": "2.1.0",
    "source": "build.gradle.kts"
  },
  "projects": [
    {
      "path": ":",
      "directory": ".",
      "declared": {
        "version": "2.1.0",
        "source": "build.gradle.kts"
      }
    },
    {
      "path": ":service",
      "directory": "service",
      "declared": null
    }
  ]
}

Collected for

GuardrailCategoryInputs
kotlin/kotlin-version-pinnedkotlinprojectDir

All collectors

Buildnote Limited
Registered in England and Wales, Reg: 16140412