Min Scala Version + Scala Collector
Enforce Min Scala Version using data collected by Scala Collector. Automatically check devex build and ci standards on every PR.
How Scala Collector Powers This Guardrail
The Scala Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Min Scala Version guardrail evaluates it against your standards.
When enabled, this check runs automatically on every PR and in AI coding workflows, providing real-time enforcement with actionable feedback.
Quick Start Configuration
Add both the collector and policy to your lunar-config.yml to enable this guardrail.
# Step 1: Enable the Scala Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/scala@v1.0.5
# with: ...
# Step 2: Enable the Scala Project Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/scala@v1.0.5
include: [min-scala-version]
# with: ...
What Scala Collector Collects
This collector gathers the following data that the Min Scala Version guardrail evaluates.
project
Analyzes Scala project structure by detecting build.sbt, project/build.properties,
build.sc (Mill), pom.xml (with scala-maven-plugin), .scalafmt.conf,
and the test source directory. Parses Scala version (scalaVersion), sbt version,
Mill version, project name/version, cross-build versions (crossScalaVersions),
detected test frameworks, and framework flags (Spark, Akka, Cats).
Skips when no *.scala source files are present (Java-only sbt /
Maven repos belong under .lang.java). Writes project metadata to
.lang.scala.
dependencies
Extracts direct dependencies from build.sbt (libraryDependencies), build.sc (Mill ivyDeps), and pom.xml. When build.sbt.lock or sbt-lock output is present, also extracts resolved transitive versions. Writes dependency data to .lang.scala.dependencies.
cicd
Records every sbt and mill command executed in CI pipelines along with the build tool version. Writes command strings and version info to .lang.scala.cicd for audit trails and build reproducibility analysis.
test-coverage
Extracts coverage percentage from scoverage XML reports (target/scala-*/scoverage-report/scoverage.xml) after sbt or Mill test runs complete. Parses coverage reports and writes results to .lang.scala.tests.coverage and the normalized .testing.coverage path.
Example Data Flow
Here's an example of the data that Scala Collector writes to the Component JSON, which Min Scala Version then evaluates.
{
"lang": {
"scala": {
"version": "2.13.12",
"build_systems": ["sbt"],
"build_sbt_exists": true,
"build_properties_exists": true,
"build_sc_exists": false,
"pom_xml_exists": false,
"scalafmt_configured": true,
"lockfile_exists": true,
"test_directory_exists": true,
"project_name": "my-app",
"project_version": "0.1.0",
"sbt_version": "1.9.7",
"mill_version": null,
"cross_scala_versions": ["2.13.12", "3.3.1"],
"is_cross_build": true,
"test_frameworks": ["scalatest", "munit"],
"frameworks": ["spark", "cats"],
"source": { "tool": "sbt", "integration": "code" },
"cicd": {
"cmds": [
{ "cmd": "sbt clean test", "version": "1.9.7" },
{ "cmd": "sbt coverage test coverageReport", "version": "1.9.7" }
]
},
"tests": {
"coverage": {
"percentage": 78.4,
"source": { "tool": "scoverage", "integration": "ci" }
}
},
"dependencies": {
"direct": [
{ "path": "org.scalatest:scalatest", "version": "3.2.18" },
{ "path": "org.apache.spark:spark-core", "version": "3.5.0" }
],
"transitive": [
{ "path": "org.scala-lang:scala-library", "version": "2.13.12" }
],
"source": { "tool": "sbt", "integration": "code" }
}
}
},
"testing": {
"coverage": {
"percentage": 78.4,
"source": { "tool": "scoverage", "integration": "ci" }
}
}
}
Configuration Options
Scala Project Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_scala_version |
Optional |
2.12
|
Minimum required Scala compiler version (e.g., "2.12", "2.13", "3.3.1"). Compared with semantic-version semantics — "2.13" matches 2.13.x and 3.x, but rejects 2.11.x. |
min_sbt_version |
Optional |
1.9
|
Minimum required sbt version (e.g., "1.9", "1.10.0"). Compared with semantic-version semantics. Skipped when the project does not use sbt. |
Ready to Automate Your Standards?
See how Lunar can turn your AGENTS.md, engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 200+ built-in guardrails.