RFR: Add build support for generating Jacoco coverage reports

Jorn Vernee jvernee at openjdk.org
Mon Dec 4 22:00:33 UTC 2023


Add a new `coverage` gradle task that can be used to generate a Jacoco test coverage report. Because we're on the bleeding edge, the user running the build needs to build Jacoco from source for this to work.

As an example: I've cloned Jacoco from here: https://github.com/jacoco/jacoco and built the project using:

    mvn package -DskipTests -Dbytecode.version=22
    
Then, I point gradle at the generated artifacts using:

    jacoco_cli=<jacoco repo>/org.jacoco.cli/target/org.jacoco.cli-0.8.12-SNAPSHOT-nodeps.jar
    jacoco_agent=<jacoco repo>/org.jacoco.agent/target/classes/jacocoagent.jar
    
I've put these in a local `gradle.properties` file instead of passing them on the command line.

I then run `./gradlew coverage` which generates an html coverage report under `./build/jacoco-report`.

-------------

Commit messages:
 - Add test coverage task

Changes: https://git.openjdk.org/jextract/pull/153/files
 Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=153&range=00
  Stats: 54 lines in 1 file changed: 39 ins; 2 del; 13 mod
  Patch: https://git.openjdk.org/jextract/pull/153.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/153/head:pull/153

PR: https://git.openjdk.org/jextract/pull/153


More information about the jextract-dev mailing list