Scala version is declared
scala/version-declared@v1
The build declares the Scala version it compiles against, and that version is no older than the configured floor.
| Id | scala/version-declared |
| Version | v1 |
| Category | scala |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | scala |
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.
| Collector | Gathers | Inputs it is given |
|---|---|---|
scala | The sbt build in the project directory: the Scala and sbt versions it pins, every subproject the reader saw, the library dependencies each build file names with their configurations, and the plugins the build itself runs. build.sbt is Scala rather than a declaration, so what it declares indirectly is not seen and scanned says so. | 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
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "scala/version-declared@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minVersion": "2.13"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minVersion | Oldest Scala version accepted. A declared version below this is a violation. | 2.13 | GUARDRAIL_INPUT_MINVERSION |
How to fix
Declare the compiler once in build.sbt, so every subproject inherits it:
ThisBuild / scalaVersion := "3.4.1"Without it sbt compiles against the Scala version its own launcher was built with, so the compiler that produced the artifact is a property of the machine that ran the build rather than of the checkout, and it changes under you the day the launcher does.
More in scala
scala/dependencies-pinned. Every library dependency read out of the build names a literal revision.build.sbtis Scala read by pattern, so a dependency built by a function, added inside a condition or held in a variable is not seen and the list is a floor rather than the whole of it.scala/no-snapshot-dependencies. No library dependency read out of the build is a-SNAPSHOT.build.sbtis Scala read by pattern, so the dependencies it declares indirectly are not seen and the list is a floor rather than the whole of it.scala/sbt-version-pinned.project/build.propertiespins the sbt version the build runs under, rather than leaving it to the launcher the machine happens to carry.