Hamburger Cross Icon
Kotlin Collector - Lunar Collector

Kotlin Collector

Collector Beta LanguagesBuild

Analyze Kotlin projects to collect project metadata, dependencies, CI/CD command tracking, and test coverage. Supports Gradle (Kotlin & Groovy DSL) and Maven. Detects the Kotlin version, JVM/Android/Multiplatform targets, test frameworks (JUnit, Kotest, MockK), and detekt/ktlint.

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

What This Integration Collects

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

Collector code

project

Analyzes Kotlin project structure by detecting build.gradle.kts, build.gradle (Groovy DSL applying a Kotlin plugin), settings.gradle(.kts), pom.xml (with kotlin-maven-plugin), gradle/libs.versions.toml (version catalog), gradle.lockfile, the Gradle wrapper, detekt/ktlint config, and the test source directory. Parses the Kotlin compiler version (from the Gradle kotlin(...) plugin, pom <kotlin.version>, or the version catalog), project name/version, Gradle version, detected test frameworks, framework flags (Ktor, Spring, Compose, Coroutines), and the JVM / Android / Multiplatform target. Skips when no *.kt / *.kts source files are present. Writes project metadata to .lang.kotlin.

kotlin gradle kotlin dsl build.gradle.kts kotlin-maven-plugin android multiplatform ktor
Book a demo
Collector code

dependencies

Extracts direct dependencies from build.gradle.kts / build.gradle (dependencies block, including libs. version-catalog references), pom.xml, or gradle/libs.versions.toml. When gradle.lockfile is present, also extracts resolved transitive versions. Writes dependency data to .lang.kotlin.dependencies.

kotlin dependencies gradle dependencies version catalog libs.versions.toml supply chain
Book a demo
Collector ci-before-command

cicd

Records every kotlinc / kotlin command executed in CI pipelines along with the compiler version. Writes command strings and version info to .lang.kotlin.cicd for audit trails and build reproducibility analysis. Gradle and Maven invocations are already tracked by the java collector's gradle-cicd / maven-cicd sub-collectors, so this focuses on direct Kotlin-compiler usage.

kotlin ci kotlinc ci commands build tracking
Book a demo
Collector ci-after-command

test-coverage

Extracts coverage percentage from Kover XML reports (build/reports/kover/report.xml) after a Gradle test / koverXmlReport run. Kover is the Kotlin-native coverage tool; JaCoCo is intentionally left to the java collector's test-coverage sub-collector — matching the per-language convention (scala→scoverage, java→jacoco, kotlin→kover) and avoiding a double-write to the normalized .testing.coverage path. Writes to .lang.kotlin.tests.coverage and .testing.coverage.

kover kotlin test coverage gradle 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": {
    "kotlin": {
      "version": "1.9.22",
      "build_systems": ["gradle"],
      "build_gradle_kts_exists": true,
      "build_gradle_exists": false,
      "settings_gradle_exists": true,
      "pom_xml_exists": false,
      "version_catalog_exists": true,
      "gradlew_exists": true,
      "lockfile_exists": false,
      "detekt_configured": true,
      "ktlint_configured": false,
      "test_directory_exists": true,
      "project_name": "my-service",
      "project_version": "0.1.0",
      "gradle_version": "8.5",
      "target": "jvm",
      "is_multiplatform": false,
      "is_android": false,
      "test_frameworks": ["junit", "kotest", "mockk"],
      "frameworks": ["ktor", "coroutines"],
      "source": { "tool": "gradle", "integration": "code" },
      "cicd": {
        "cmds": [
          { "cmd": "kotlinc src -include-runtime -d app.jar", "version": "1.9.22" }
        ]
      },
      "tests": {
        "coverage": {
          "percentage": 81.3,
          "source": { "tool": "kover", "integration": "ci" }
        }
      },
      "dependencies": {
        "direct": [
          { "path": "io.ktor:ktor-server-core", "version": "2.3.7" },
          { "path": "org.jetbrains.kotlinx:kotlinx-coroutines-core", "version": "1.7.3" }
        ],
        "transitive": [
          { "path": "org.jetbrains.kotlin:kotlin-stdlib", "version": "1.9.22" }
        ],
        "source": { "tool": "gradle", "integration": "code" }
      }
    }
  },
  "testing": {
    "coverage": {
      "percentage": 81.3,
      "source": { "tool": "kover", "integration": "ci" }
    }
  }
}

Documentation

View on GitHub

Kotlin Collector

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

Overview

This collector gathers metadata about Kotlin projects from build.gradle.kts, build.gradle, pom.xml, and the Gradle version catalog, plus runtime CI signals like test coverage and Kotlin-compiler command usage. All sub-collectors gate on *.kt / *.kts source presence — Groovy/Maven Java-only repos land under .lang.java. The CI-hook collectors (cicd, test-coverage) observe commands your pipeline already runs; they do not invoke builds or tests.

Collected Data

This collector writes to the following Component JSON paths:

Path Type Description
.lang.kotlin object Kotlin project metadata
.lang.kotlin.version string Kotlin compiler version (e.g. "1.9.22")
.lang.kotlin.build_systems array Build systems detected (["gradle"], ["maven"], or combinations)
.lang.kotlin.build_gradle_kts_exists boolean build.gradle.kts detected (Gradle Kotlin DSL)
.lang.kotlin.build_gradle_exists boolean build.gradle detected (Gradle Groovy DSL applying a Kotlin plugin)
.lang.kotlin.settings_gradle_exists boolean settings.gradle(.kts) detected
.lang.kotlin.pom_xml_exists boolean pom.xml with kotlin-maven-plugin detected
.lang.kotlin.version_catalog_exists boolean gradle/libs.versions.toml version catalog detected
.lang.kotlin.gradlew_exists boolean Gradle wrapper (gradlew) detected
.lang.kotlin.lockfile_exists boolean gradle.lockfile (Gradle dependency locking) detected
.lang.kotlin.detekt_configured boolean detekt config (detekt.yml) detected
.lang.kotlin.ktlint_configured boolean ktlint config (ktlint Gradle plugin or .editorconfig) detected
.lang.kotlin.test_directory_exists boolean src/test/kotlin (or Android/Multiplatform variant) detected
.lang.kotlin.project_name string Project name (Gradle rootProject.name or Maven artifactId)
.lang.kotlin.project_version string Project version (Gradle version or Maven version)
.lang.kotlin.gradle_version string Gradle version from gradle/wrapper/gradle-wrapper.properties
.lang.kotlin.target string Primary target: "jvm", "android", or "multiplatform"
.lang.kotlin.is_multiplatform boolean True when the Kotlin Multiplatform plugin is applied
.lang.kotlin.is_android boolean True when an Android Gradle plugin is applied
.lang.kotlin.test_frameworks array Detected test frameworks (e.g. ["junit", "kotest", "mockk"])
.lang.kotlin.frameworks array Detected frameworks from deps (e.g. ["ktor", "spring", "compose", "coroutines"])
.lang.kotlin.cicd object CI/CD command tracking with compiler version
.lang.kotlin.tests object Test coverage information
.lang.kotlin.dependencies object Direct and transitive dependencies
.testing.coverage object Normalized cross-language test coverage

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

Collectors

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

Collector Hook Type Description
project code Collects project structure, versions, target, framework detection, test framework detection
dependencies code Collects dependencies from build.gradle.kts, build.gradle, pom.xml, or the version catalog
cicd ci-before-command Tracks kotlinc/kotlin commands run in CI with compiler version
test-coverage ci-after-command Extracts coverage from Kover XML reports (Kotlin-native; JaCoCo is left to the java collector)

Note on Gradle/Maven CI commands: gradle/gradlew and mvn/mvnw invocations are already tracked by the java collector's gradle-cicd / maven-cicd sub-collectors (they fire regardless of language), so this collector's cicd sub-collector focuses on direct Kotlin-compiler usage rather than duplicating that data.

Installation

Add to your lunar-config.yml:

collectors:
  - uses: github://earthly/lunar-lib/collectors/kotlin@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