Scala Collector
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).
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.
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.
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 →Example Collected Data
This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:
{
"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 GitHubScala 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.
Common Use Cases
Explore guardrails that use data from Scala Collector.
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.