Repository with useful and usable software components used in the Software Engineering Done Right book.
Shared Java annotations and utilities for Software Engineering Done Right projects.
Latest version |
|
Group ID |
|
Artifact ID |
|
| Class | Package | Description |
|---|---|---|
|
|
Marker annotation to exclude constructors, methods, or types from JaCoCo code-coverage measurement. |
The library is published to GitHub Packages.
Unlike Maven Central, GitHub Packages requires authentication even for public packages.
You need a GitHub Personal Access Token (PAT) with the read:packages scope.
Add the following to ~/.gradle/gradle.properties (create the file if it does not exist).
Never commit this file — it lives outside your project.
gpr.user=<your-github-username>
gpr.key=<your-github-pat>build.gradle.kts)repositories {
maven {
url = uri("https://maven.pkg.github.com/Arc-E-Tect/SoftwareEngineeringDoneRight-Library")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}build.gradle)repositories {
maven {
url = uri('https://maven.pkg.github.com/Arc-E-Tect/SoftwareEngineeringDoneRight-Library')
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR')
password = project.findProperty('gpr.key') ?: System.getenv('GITHUB_TOKEN')
}
}
}pom.xml)<repositories>
<repository>
<id>github-sedr-library</id>
<url>https://maven.pkg.github.com/Arc-E-Tect/SoftwareEngineeringDoneRight-Library</url>
</repository>
</repositories>For Maven, add your credentials to ~/.m2/settings.xml:
<settings>
<servers>
<server>
<id>github-sedr-library</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>dependencies {
implementation("com.arc-e-tect.sedr.utils:sedr-library:0.3.4")
}dependencies {
implementation 'com.arc-e-tect.sedr.utils:sedr-library:0.3.4'
}<dependency>
<groupId>com.arc-e-tect.sedr.utils</groupId>
<artifactId>sedr-library</artifactId>
<version>0.3.4</version>
</dependency>In GitHub Actions, GITHUB_ACTOR and GITHUB_TOKEN are injected automatically — no extra secrets are needed when consuming the package from within a GitHub Actions workflow.
- name: Build
run: ./gradlew build
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}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.
dependencies {
testImplementation(testFixtures("com.arc-e-tect.sedr.utils:sedr-library:0.3.4"))
}dependencies {
testImplementation testFixtures('com.arc-e-tect.sedr.utils:sedr-library:0.3.4')
}The test-fixtures artifact brings archunit-junit5 and junit-jupiter-api in as transitive dependencies, so no extra entries are needed for those.
You do need to add the JUnit Jupiter engine for test execution:
dependencies {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.14.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.14.4'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}Extend AbstractCoverageExclusionConventionsTest and override getBasePackage() to scope the rule to your project’s root package.
class CoverageExclusionConventionsTest extends AbstractCoverageExclusionConventionsTest {
@Override
protected String getBasePackage() {
return "com.example.myapp";
}
}The inherited test coverageExclusionAnnotationsMustHaveJustification() runs automatically and fails if any class, constructor, or method in the scanned packages carries @ExcludeFromJacocoGeneratedCodeCoverage without a non-blank justification.
@ExcludeFromJacocoGeneratedCodeCoverage(
justification = "Spring Boot entry point – not unit-testable")
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}@ExcludeFromJacocoGeneratedCodeCoverage // missing justification
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}A self-contained example demonstrating both compliant and non-compliant usage is located at examples/sedr-library/jacoco-marker/.
| File | Purpose |
|---|---|
|
Uses |
|
Uses |
|
Extends |
To run the example (requires the library to be published to your local Maven repository first):
# 1. Publish the library locally
cd sedr-library && ./gradlew clean build publishToMavenLocal
# 2. Run the example — expected to FAIL with one ArchUnit violation
cd ../examples/sedr-library/jacoco-marker && ./gradlew testThe test run reports exactly one violation:
Method NonCompliantService.stop() uses @ExcludeFromJacocoGeneratedCodeCoverage without a justification.
CompliantService is not mentioned.