From 85b734a6bdd9e0b001e1eb45e96434572bf7688d Mon Sep 17 00:00:00 2001 From: Iwan Eising Date: Sun, 21 Jun 2026 19:34:29 +0400 Subject: [PATCH] maintenance: enhance JaCoCo integration and documentation for exclusion annotation --- README.adoc | 3 ++- .../single-module-spring/build.gradle | 8 ++++++++ examples/sedr-library/jacoco-marker/build.gradle | 8 ++++++++ hexagonal-spring-rules/build.gradle | 11 +++++++++++ sedr-library/build.gradle | 11 +++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 7a6e3d1..9111d74 100644 --- a/README.adoc +++ b/README.adoc @@ -25,7 +25,7 @@ Shared Java annotations and utilities for _Software Engineering Done Right_ proj |`ExcludeFromJacocoGeneratedCodeCoverage` |`com.arc_e_tect.sedr.utils.jacoco.marker` -|Marker annotation to exclude constructors, methods, or types from JaCoCo code-coverage measurement. +|Marker annotation to document constructors, methods, or types that should be treated as excluded from JaCoCo code-coverage measurement, with an ArchUnit rule that enforces a justification. |=== === Adding the dependency @@ -146,6 +146,7 @@ In GitHub Actions, `GITHUB_ACTOR` and `GITHUB_TOKEN` are injected automatically The library ships a `test-fixtures` artifact that contains the reusable ArchUnit rule `AbstractCoverageExclusionConventionsTest`. It verifies that every use of `@ExcludeFromJacocoGeneratedCodeCoverage` in your production code carries a non-blank `justification`. +The Gradle builds in this repository use Gradle's native JaCoCo support, with the JaCoCo tool version managed through `refreshVersions` in each build. ==== Add the test-fixtures dependency diff --git a/examples/architecture-validator/single-module-spring/build.gradle b/examples/architecture-validator/single-module-spring/build.gradle index 45df48d..d1939c1 100644 --- a/examples/architecture-validator/single-module-spring/build.gradle +++ b/examples/architecture-validator/single-module-spring/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'jacoco' id 'java' alias(libs.plugins.architecture.validator.iff) } @@ -24,4 +25,11 @@ dependencies { architectureValidator { basePackage = 'com.arc_e_tect.example.spring' ignoreFailures = true +} + +tasks.named('jacocoTestReport') { + reports { + xml.required = true + html.required = true + } } \ No newline at end of file diff --git a/examples/sedr-library/jacoco-marker/build.gradle b/examples/sedr-library/jacoco-marker/build.gradle index 18a3c16..a2e1a5c 100644 --- a/examples/sedr-library/jacoco-marker/build.gradle +++ b/examples/sedr-library/jacoco-marker/build.gradle @@ -9,6 +9,7 @@ * ./gradlew test */ plugins { + id 'jacoco' id 'java' } @@ -37,3 +38,10 @@ dependencies { test { useJUnitPlatform() } + +tasks.named('jacocoTestReport') { + reports { + xml.required = true + html.required = true + } +} diff --git a/hexagonal-spring-rules/build.gradle b/hexagonal-spring-rules/build.gradle index 35129ed..7ad04cf 100644 --- a/hexagonal-spring-rules/build.gradle +++ b/hexagonal-spring-rules/build.gradle @@ -5,6 +5,7 @@ * gh CLI), or 1.0.0-PRERELEASE as fallback. */ plugins { + id 'jacoco' id 'java-library' id 'maven-publish' alias(libs.plugins.owasp.dependency.check.iff) @@ -68,6 +69,9 @@ java { withSourcesJar() } +jacoco { +} + repositories { mavenCentral() } @@ -179,4 +183,11 @@ tasks.withType(Javadoc).configureEach { options.links('https://docs.oracle.com/javase/21/docs/api/') options.docTitle = "Architecture Validator Spring Rules API" options.windowTitle = "Spring Hexagonal Architecture Rules (${project.version})" +} + +tasks.named('jacocoTestReport') { + reports { + xml.required = true + html.required = true + } } \ No newline at end of file diff --git a/sedr-library/build.gradle b/sedr-library/build.gradle index 3bf7cf9..8067009 100644 --- a/sedr-library/build.gradle +++ b/sedr-library/build.gradle @@ -5,6 +5,7 @@ * Publish: ./gradlew publishToMavenLocal */ plugins { + id 'jacoco' id 'java-library' id 'java-test-fixtures' id 'maven-publish' @@ -56,6 +57,9 @@ java { withSourcesJar() } +jacoco { +} + repositories { mavenCentral() } @@ -139,3 +143,10 @@ jreleaser { } } } + +tasks.named('jacocoTestReport') { + reports { + xml.required = true + html.required = true + } +}