Tests All Modules + Java Collector
Enforce Tests All Modules 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 Tests All Modules 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.0
# with: ...
# Step 2: Enable the Java Project Guardrails
policies:
- uses: github://earthly/lunar-lib/policies/java@v1.0.0
include: [tests-all-modules]
# with: ...
What Java Collector Collects
This collector gathers the following data that the Tests All Modules 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.
java-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.cicd.cmds.
Example Data Flow
Here's an example of the data that Java Collector writes to the Component JSON, which Tests All Modules 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", "tool": "java" },
{ "cmd": "mvn clean install", "version": "3.9.6", "tool": "maven" }
],
"source": { "tool": "java", "integration": "ci" }
},
"tests": {
"scope": "all",
"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" }
}
}
}
}
Configuration Options
Java Project Guardrails Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_java_version |
Optional |
17
|
Minimum required Java version (e.g., "17", "21") |
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") |
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.