Min Maven Version + Java Collector
Enforce Min Maven Version using data collected by Java Collector. Automatically check devex build and ci standards on every PR.
How Java Collector Powers This Guardrail
The Java Collector gathers metadata from your languages, build systems. This data flows into Lunar's Component JSON, where the Min Maven 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 Java Collector
collectors:
- uses: github://earthly/lunar-lib/collectors/java@v1.0.5
# with: ...
# Step 2: Enable the Java Project Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/java@v1.0.5
include: [min-maven-version]
# with: ...
What Java Collector Collects
This collector gathers the following data that the Min Maven Version guardrail evaluates.
project
Detects Java project structure including build tools (Maven/Gradle), Java version from build config, wrapper scripts, and static analysis tool configuration. Writes project metadata to .lang.java.
dependencies
Extracts direct dependencies from pom.xml (using Python XML parsing with property resolution) or gradle.lockfile. Writes dependency data to .lang.java.dependencies.
cicd
Records java/javac commands executed in CI pipelines along with the Java version. Writes command strings and version info to .lang.java.cicd.cmds.
maven-cicd
Records Maven commands executed in CI pipelines along with the Maven version. Detects version from installation path, wrapper properties, or mvn --version. Writes to .lang.java.maven.cicd.cmds.
Example Data Flow
Here's an example of the data that Java Collector writes to the Component JSON, which Min Maven Version then evaluates.
{
"lang": {
"java": {
"version": "17",
"build_systems": ["maven"],
"pom_xml_exists": true,
"build_gradle_exists": false,
"mvnw_exists": true,
"gradlew_exists": false,
"gradle_lockfile_exists": false,
"checkstyle_configured": true,
"spotbugs_configured": false,
"source": { "tool": "java", "integration": "code" },
"cicd": {
"cmds": [
{ "cmd": "java -jar app.jar", "version": "17.0.2" }
]
},
"maven": {
"cicd": {
"cmds": [
{ "cmd": "mvn clean install", "version": "3.9.6" }
]
}
},
"sbt": {
"cicd": {
"cmds": [
{ "cmd": "sbt test", "version": "1.9.7" }
]
}
},
"tests": {
"scope": "all",
"results": {
"total": 156,
"passed": 152,
"failed": 1,
"skipped": 3,
"source": { "tool": "maven", "integration": "ci" }
},
"coverage": {
"percentage": 72.5,
"source": { "tool": "jacoco", "integration": "ci" }
}
},
"dependencies": {
"direct": [
{ "path": "org.springframework:spring-core", "version": "6.1.3", "indirect": false }
],
"transitive": [],
"source": { "tool": "maven", "integration": "code" }
}
}
},
"testing": {
"source": { "tool": "maven-surefire", "integration": "ci" },
"results": { "total": 156, "passed": 152, "failed": 1, "skipped": 3 },
"all_passing": false,
"runs": [
{
"pipeline": "CI",
"run_id": "36909154652",
"attempt": 1,
"job": "build",
"step": 4,
"total": 156,
"passed": 152,
"failed": 1,
"skipped": 3,
"all_passing": false
}
],
"coverage": {
"percentage": 72.5,
"source": { "tool": "jacoco", "integration": "ci" }
}
}
}
Configuration Options
Java Project Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_java_version |
Optional |
17
|
Minimum Java version, as a feature release ("17"), a specific update ("21.0.13.1") or one minimum per feature release ("21.0.13.1, 25.0.5.1, 27.0.1.1") |
min_java_version_cicd |
Optional |
17
|
Minimum Java version for java/javac commands in CI, in the same forms as min_java_version |
min_java_version_base_image |
Optional |
17
|
Minimum Java version for runtime base images in Dockerfiles, in the same forms as min_java_version |
java_base_image_families |
Required | — | Java base images to check, one per line as a repository pattern and a version scheme (temurin, version, chainguard or distro); a `defaults` line adds the built-in list. Empty uses the built-in list |
min_maven_version |
Optional |
3.9.0
|
Minimum required Maven version (e.g., "3.9.0") |
min_gradle_version |
Optional |
8.0.0
|
Minimum required Gradle version (e.g., "8.0.0") |
require_java_version_cicd |
Optional |
false
|
Set to "true" to fail min-java-version-cicd, instead of skipping, when CI recorded no Java version for a Java project. Needs the java collector's project and cicd sub-collectors |
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 300+ built-in guardrails.