Hamburger Cross Icon
Scala Collector - Lunar Collector

Scala Collector

Collector Beta LanguagesBuild

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).

Add scala to your lunar-config.yml:
uses: github://earthly/lunar-lib/collectors/scala@v1.0.5

What This Integration Collects

This integration includes 4 collectors that gather metadata from your systems.

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.

scala sbt mill build.sbt build.sc scala-maven-plugin cross-version spark akka
Book a demo
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.

scala dependencies sbt dependencies mill dependencies ivy supply chain
Book a demo
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.

scala ci sbt ci mill ci ci commands build tracking
Book a demo
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.

scoverage scala test coverage sbt test mill test coverage metrics
Book a demo

How Collectors Fit into Lunar

Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.

Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.

Learn How Lunar Works
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "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" }
    }
  }
}

Documentation

View on GitHub

Scala Collector

Collects Scala project information, dependencies, CI/CD commands, and test coverage.

Overview

This collector gathers metadata about Scala projects from build.sbt, build.sc, and pom.xml, plus runtime CI signals like test coverage and sbt/mill command usage. All sub-collectors gate on *.scala source presence — sbt/Maven Java-only repos land under .lang.java. The CI-hook collectors (cicd, test-coverage) observe sbt/mill commands your pipeline already runs; they do not invoke tests.

Collected Data

This collector writes to the following Component JSON paths:

Path Type Description
.lang.scala object Scala project metadata
.lang.scala.version string Scala compiler version (e.g. "2.13.12" or "3.3.1")
.lang.scala.build_systems array Build systems detected (["sbt"], ["mill"], ["maven"], or combinations)
.lang.scala.build_sbt_exists boolean build.sbt detected
.lang.scala.build_properties_exists boolean project/build.properties detected
.lang.scala.build_sc_exists boolean build.sc detected (Mill)
.lang.scala.pom_xml_exists boolean pom.xml with scala-maven-plugin detected
.lang.scala.scalafmt_configured boolean .scalafmt.conf detected
.lang.scala.lockfile_exists boolean build.sbt.lock or sbt-lock plugin output detected
.lang.scala.test_directory_exists boolean src/test/scala (or cross-version variant) detected
.lang.scala.project_name string Project name (name := in build.sbt, or Maven artifactId)
.lang.scala.project_version string Project version (version := in build.sbt, or Maven version)
.lang.scala.sbt_version string sbt version from project/build.properties (when sbt is the build tool)
.lang.scala.mill_version string Mill version from .mill-version or build.sc header (when Mill is used)
.lang.scala.cross_scala_versions array Versions declared via crossScalaVersions (empty when not a cross-build)
.lang.scala.is_cross_build boolean True when crossScalaVersions declares more than one entry
.lang.scala.test_frameworks array Detected test frameworks (e.g. ["scalatest", "munit", "specs2"])
.lang.scala.frameworks array Detected frameworks from deps (e.g. ["spark", "akka", "cats"])
.lang.scala.cicd object CI/CD command tracking with build tool version
.lang.scala.tests object Test coverage information
.lang.scala.dependencies object Direct and transitive dependencies
.testing.coverage object Normalized cross-language test coverage

Note: When a Scala project is detected, .lang.scala is always created (with at minimum source metadata), so policies can use its existence as a signal that the component is a Scala project.

Collectors

This plugin provides the following collectors (use include to select a subset):

Collector Hook Type Description
project code Collects project structure, versions, cross-build info, framework flags, test framework detection
dependencies code Collects dependencies from build.sbt, build.sc, or pom.xml
cicd ci-before-command Tracks sbt/mill commands run in CI with build tool version
test-coverage ci-after-command Extracts coverage from scoverage XML reports

Installation

Add to your lunar-config.yml:

collectors:
  - uses: github://earthly/lunar-lib/collectors/scala@main
    on: ["domain:your-domain"]  # replace with your own domain or tags
    # include: [project, dependencies]  # Only include specific subcollectors

Open Source

This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

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