Skip to content

Building and Testing

Petrus Pradella edited this page Jun 27, 2026 · 2 revisions

Building & Testing

Prerequisites

  • JDK 25 — the only JDK you need to launch the build. The wrapper is Gradle 9.5.1 (runs on JDK 25 directly). One toolchain compiles and runs everything.
  • The published bytecode targets Java 8: production sources compile on the Java 25 toolchain via Jabel (a fork that supports a Java 25 javac), with options.release = 8 keeping the API floor honest.
  • Auto-download is off; Gradle auto-detects locally installed JDKs (including ~/.jdks). A JDK in a non-standard location can be pointed at from your own ~/.gradle/gradle.properties.

Build

export JAVA_HOME=/path/to/jdk-25      # PowerShell: $env:JAVA_HOME = "C:\path\to\jdk-25"

./gradlew build                       # compile + run all tests on Java 25
./gradlew shadowJar                   # (n/a — EveryConfig ships a thin jar; see Installation)
./gradlew publishToMavenLocal         # install br.com.finalcraft:EveryConfig:1.0.1 to ~/.m2

The Java 8 runtime floor

Jabel lifts syntax but not runtime APIs, so production and test code avoid Java 9+ APIs (List.of, String.repeat, Files.readString, record, …). The guard is running the suite on a Java 8 runtime:

./gradlew test -PtestJdk=8            # also: 11, 17, 21, 25 (default is 25)

Test bytecode is compiled to the Java 8 floor too (compileTestJava uses --release 8), so the suite can run on a Java 8 JVM. The library is validated green on Java 8, 11, 17, 21 and 25.

The codec-agnostic contract

AbstractConfigTest holds the format-agnostic tests; one thin subclass per codec runs the whole body, so a behavior is validated identically on YAML, JSON, TOML and JSONC.

src/test/java/.../config/
├── data/                # shared DTOs (Dtos) — one per scenario
└── modules/
    ├── AbstractConfigTest.java       # the generic contract + a residuals harness
    ├── json/JsonConfigTest.java      # newCodec()=JsonCodec, fidelity=NONE
    ├── yaml/YamlConfigTest.java      # newCodec()=YamlCodec, fidelity=LOSSLESS
    ├── toml/TomlConfigTest.java      # newCodec()=TomlCodec, supportsNull()=false
    └── jsonc/JsoncConfigTest.java    # newCodec()=JsoncCodec, fidelity=LOSSY

A new subclass supplies a Codec, the file extension and a comment-fidelity flag; capability-gated tests (comments, null) skip on codecs that don't support them via JUnit Assumptions.

Residuals

Real files are written under build/test-residuals/<ext>/<method>/ and kept for inspection by default (flip CLEAN_TEST_RESIDUALS in AbstractConfigTest to delete them). This lets you diff how the same scenario renders across all four formats.

Running specific tests

./gradlew test --tests "*YamlConfigTest"
./gradlew test --tests "br.com.finalcraft.everyconfig.config.modules.*"   # all four codec contracts
./gradlew cleanTest test -PtestJdk=8                                       # force a re-run on Java 8

→ See also Project Layout · Installation

Clone this wiki locally