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 key | kotlin |
| Version | v1 |
| Script | kotlin.py |
| Timeout | 30 seconds |
| Collects from | gradle, 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.
| Collector | Gathers |
|---|---|
| gradle | The 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. |
| maven | The 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
| Input | Description | Default | Environment |
|---|---|---|---|
projectDir | Directory 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:
{
"collect": ["kotlin"]
}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.
| Fact | Meaning |
|---|---|
directory | The projectDir input, as the guardrail configured it. |
exists | Whether 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. |
sources | The Gradle and Maven build files that were there to read, Gradle first. |
declared | Where 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.version | The version declared. |
declared.source | The file declaring it. |
projects | The root project followed by every project the Gradle settings file includes. |
projects[].path | Gradle path of the project, : for the root. |
projects[].directory | Directory holding it, relative to projectDir. |
projects[].declared | Where 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:
{
"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
| Guardrail | Category | Inputs |
|---|---|---|
kotlin/kotlin-version-pinned | kotlin | projectDir |