Hamburger Cross Icon
Tests All Modules
+
Java Collector

Tests All Modules + Java Collector

Guardrail Collector Beta Devex Build And Ci

Enforce Tests All Modules using data collected by Java Collector. Automatically check devex build and ci standards on every PR.

Guardrail: Ensures tests run across all modules rather than a subset. Prevents accidentally skipping tests in multi-module projects.
Data Source: Analyze Java projects to collect build tool info, dependencies, CI/CD command tracking, test scope, and JaCoCo coverage. Supports Maven and Gradle.

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.

1
Java Collector Gathers Data Collector
Extracts metadata from code, configs, and tool outputs
2
{ } Component JSON
Data centralized in structured format for evaluation
3
Tests All Modules Checks Guardrail
Pass/fail result with actionable feedback in PRs

Quick Start Configuration

Add both the collector and policy to your lunar-config.yml to enable this guardrail.

📄 lunar-config.yml
# 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.

Collector code

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.

Collector code

dependencies

Extracts direct dependencies from pom.xml (using Python XML parsing with property resolution) or gradle.lockfile. Writes dependency data to .lang.java.dependencies.

Collector ci-before-command

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.

Collector ci-before-command

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.

{ } component.json From Java Collector
{
  "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.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Turn any process doc into guardrails
Book a Demo