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 works out its facts from the collectors below. The CLI runs those first, passes their results to kotlin, and then gives 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 |
When a guardrail declares an input with the same name, it passes its value through. That means you set these values in the guardrail's configuration in buildnote.json.
A guardrail asks for these facts by name and reads them back by the same name:
{
"collect": ["kotlin"]
}kotlin = guardrail.facts("kotlin")Facts
These are the fields of the document kotlin collects. In a path, [] means each entry of the list before it, and [path] means a key of the object before it.
| Fact | Meaning |
|---|---|
directory | The project directory set by the guardrail's projectDir input, relative to the directory the CLI runs in. Every other path this collector reports is also relative to the directory the CLI runs in, so it resolves from where you invoked the CLI, not from wherever the collector happened to run. |
exists | Whether the Gradle or Maven build reports that the directory exists. When it doesn't, nothing else is collected, and when neither build collected anything, this collector collects nothing at all. |
sources | The Gradle and Maven build files that were present to read, Gradle first. |
declared | Where the Kotlin version is declared, or null when nothing declares one. The project's own Gradle manifest wins over the manifest of the Gradle build's root, which wins over the version catalog, and Gradle wins over Maven. |
declared.version | The version declared. |
declared.source | The file declaring it, from the directory the CLI runs in, so a version a module inherits from its build root shows the root's file. |
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, from the directory the CLI runs in. |
projects[].declared | Where that project declares its own Kotlin version, shaped as above, or null. |
If a collector can't finish, it prints what it gathered so far along with an incomplete key that says why. Facts after the point where it stopped are missing, so a check that depends on them should read incomplete first.
Example facts
Here are the facts the kotlin collector gathers from an example project:
{
"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 |