Hamburger Cross Icon
Min Scala Version
+
Scala Collector

Min Scala Version + Scala Collector

Guardrail Collector Beta Devex Build And Ci

Enforce Min Scala Version using data collected by Scala Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures the declared Scala compiler version meets the configured minimum (default: "2.12"). Reads `.lang.scala.version` (parsed from `scalaVersion` / `<scala.version>` / Mill `def scalaVersion`). Skips when the version is not detected — pair with `scala-version-pinned` if you want presence to be enforced too.
Data Source: Analyze Scala projects to collect project metadata, dependencies, CI/CD command tracking, and test coverage. Supports sbt, Mill, and Maven (via scala-maven-plugin). Detects cross-version builds, test frameworks (ScalaTest, MUnit, Specs2), and data-engineering frameworks (Spark, Akka, Cats).

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.

1
Scala Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Min Scala Version Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# 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.

Collector code

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.

Collector code

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.

Collector ci-before-command

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.

Collector ci-after-command

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.

{ } component.json From Scala Collector
{
  "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.

Works with any process
check AI agent rules & prompt files
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Paste your AGENTS.md or manual process doc and get guardrails in minutes
Book a Demo