Skip to content

Commit 6f76901

Browse files
authored
Initial project submission: JaCoCo Console Reporter Maven Plugin (#1)
A Maven plugin that provides a clear, console-based view of JaCoCo coverage data. Key Features: Console-based reporting without need for HTML/XML reports Tree-like package structure visualization Coverage metrics for classes, methods, branches, and lines Clean integration with existing JaCoCo executions The plugin aims to provide quick insights into code coverage directly in your build output, making it easier to spot coverage issues without switching context to external reports. Built with Java 8 compatibility in mind
1 parent d6989b9 commit 6f76901

File tree

16 files changed

+1339
-2
lines changed

16 files changed

+1339
-2
lines changed

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "monday"
8+
open-pull-requests-limit: 10
9+
groups:
10+
maven-plugins:
11+
patterns:
12+
- "org.apache.maven.plugins:*"
13+
test-dependencies:
14+
patterns:
15+
- "org.junit*"
16+
- "junit:junit"
17+
jacoco:
18+
patterns:
19+
- "org.jacoco:*"
20+
ignore:
21+
# Ignore patch updates for Maven plugins to reduce noise
22+
- dependency-name: "org.apache.maven.plugins:*"
23+
update-types: ["version-update:semver-patch"]
24+
25+
- package-ecosystem: "github-actions"
26+
directory: "/"
27+
schedule:
28+
interval: "weekly"
29+
day: "monday"
30+
open-pull-requests-limit: 10

.github/workflows/build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
java: ['8', '11', '17', '21']
16+
fail-fast: false
17+
18+
name: Java ${{ matrix.java }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: ${{ matrix.java }}
26+
distribution: 'temurin'
27+
cache: 'maven'
28+
29+
- name: Build and test
30+
run: mvn -B verify
31+
32+
- name: Upload test results
33+
if: always()
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: test-results-java-${{ matrix.java }}
37+
path: '**/target/surefire-reports/'
38+
39+
- name: Upload coverage report
40+
if: always()
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: coverage-report-java-${{ matrix.java }}
44+
path: '**/target/site/jacoco/'
45+
46+
- name: Upload test results to Codecov
47+
if: ${{ !cancelled() }}
48+
uses: codecov/test-results-action@v1
49+
with:
50+
token: ${{ secrets.CODECOV_TOKEN }}
51+
52+
- name: Upload coverage reports to Codecov
53+
if: ${{ !cancelled() }}
54+
uses: codecov/codecov-action@v5
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# .github/workflows/release.yml
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- '[0-9]+.[0-9]+.[0-9]+' # Matches semantic versions like 1.0.0
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Required for getting tag information
20+
21+
- name: Set up JDK
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '8'
25+
distribution: 'temurin'
26+
cache: 'maven'
27+
server-id: ossrh
28+
server-username: MAVEN_USERNAME
29+
server-password: MAVEN_PASSWORD
30+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
31+
32+
- name: Set version from tag
33+
run: |
34+
VERSION=${GITHUB_REF#refs/tags/}
35+
echo "Setting version to $VERSION"
36+
mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false
37+
38+
- name: Build and Deploy to OSSRH
39+
run: |
40+
mvn -B clean deploy -pl jacoco-console-reporter -am -P release
41+
env:
42+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
43+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
44+
45+
- name: Create GitHub Release
46+
uses: softprops/action-gh-release@v1
47+
with:
48+
files: |
49+
jacoco-console-reporter/target/*.jar
50+
!jacoco-console-reporter/target/*-sources.jar
51+
!jacoco-console-reporter/target/*-javadoc.jar
52+
generate_release_notes: true
53+
tag_name: ${{ github.ref_name }} # Use the tag name for the release
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
replay_pid*
25+
26+
27+
# My own stuff
28+
.idea/
29+
target/
30+
build/

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
1-
# jacoco-console-reporter
2-
Read JaCoCo's coverage information and outputs a tabular report of coverage metrics (classes, methods, lines, and branches).
1+
# Jacoco Console Reporter Maven Plugin
2+
3+
A custom Maven plugin that generates a textual tree-like coverage report from JaCoCo's `jacoco.exec` file, displaying coverage metrics (Class %, Method %, Branch %, Line %) for packages, source files, and the entire project.
4+
5+
## Features
6+
- Reads coverage data from `jacoco.exec`
7+
- Analyzes class files from the project's build output directory
8+
- Outputs a hierarchical console-based report with coverage metrics
9+
- Tree-like package structure visualization
10+
- Instant visibility of coverage metrics during build
11+
12+
## Prerequisites
13+
- Maven 3.x
14+
- JaCoCo plugin configured in your project to generate `jacoco.exec`
15+
16+
## Installation
17+
Add the plugin to your project's pom.xml:
18+
```xml
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>io.github.svaningelgem</groupId>
23+
<artifactId>jacoco-console-reporter</artifactId>
24+
<version>1.0.0</version>
25+
<executions>
26+
<execution>
27+
<goals>
28+
<goal>report</goal>
29+
</goals>
30+
<phase>verify</phase>
31+
</execution>
32+
</executions>
33+
</plugin>
34+
</plugins>
35+
</build>
36+
```
37+
38+
## Usage
39+
Run the plugin after tests:
40+
```bash
41+
mvn verify
42+
```
43+
44+
Ensure the JaCoCo plugin has executed beforehand to generate jacoco.exec.
45+
46+
## Configuration
47+
48+
* `jacocoExecFile`: Path to `jacoco.exec` (default: `${project.build.directory}/jacoco.exec`)
49+
* `classesDirectory`: Directory containing compiled classes (default: `${project.build.outputDirectory}`)
50+
51+
## Example Output
52+
```text
53+
[INFO] Overall Coverage Summary
54+
[INFO] Package | Class, % | Method, % | Branch, % | Line, %
55+
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
56+
[INFO] com.example | 50.00% (1/2) | 33.33% (2/6) | 25.00% (1/4) | 40.00% (4/10)
57+
[INFO] ├─ Calculator.java | 50.00% (1/2) | 50.00% (1/2) | 0.00% (0/0) | 50.00% (1/2)
58+
[INFO] └─ AdvancedCalculator.java | 100.00% (1/1) | 25.00% (1/4) | 25.00% (1/4) | 37.50% (3/8)
59+
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------------------
60+
[INFO] all classes | 75.00% (2/3) | 33.33% (2/6) | 25.00% (1/4) | 40.00% (4/10)
61+
```
62+
63+
## Contributing
64+
Contributions are welcome! Feel free to submit issues or pull requests to enhance this plugin.

docs/gpg.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
3+
4+
## Generate keys
5+
```bash
6+
gpg --gen-key
7+
```
8+
## List them
9+
```bash
10+
gpg --list-keys
11+
```
12+
Output is like:
13+
```text
14+
$ gpg --list-secret-keys --keyid-format=long
15+
/home/steven/.gnupg/pubring.kbx
16+
-------------------------------
17+
sec rsa3072/99CEEF7F4D5085C2 2025-02-22 [SC] [expires: 2027-02-22]
18+
1620F76B23ACC52D73DDEB8C99CEEF7F4D5085C2
19+
uid [ultimate] Steven Van Ingelgem <[email protected]>
20+
ssb rsa3072/3D2ADE7187466D99 2025-02-22 [E] [expires: 2027-02-22]
21+
```
22+
23+
## Upload them
24+
```bash
25+
gpg --keyserver keyserver.ubuntu.com --send-keys 99CEEF7F4D5085C2
26+
```
27+
28+
## Show the public key
29+
```bash
30+
gpg --armor --export 99CEEF7F4D5085C2
31+
```
32+
Output:
33+
```text
34+
-----BEGIN PGP PUBLIC KEY BLOCK-----
35+
[...]
36+
-----END PGP PUBLIC KEY BLOCK-----
37+
```
38+
39+
## Set the GPG key in your github profile
40+
URL: https://github.com/settings/keys
41+
42+
## Export the private key
43+
```bash
44+
gpg --armor --export-secret-key [email protected]
45+
```
46+
Output:
47+
```text
48+
-----BEGIN PGP PRIVATE KEY BLOCK-----
49+
[...]
50+
-----END PGP PRIVATE KEY BLOCK-----
51+
```

0 commit comments

Comments
 (0)