[BUILD-543] Replace Clover with JaCoCo Created: 24/Sep/21  Updated: 24/Mar/22  Resolved: 24/Mar/22

Status: Closed
Project: Build
Component/s: Poms
Affects Version/s: POMs 42
Fix Version/s: POMs 45

Type: Task Priority: Neutral
Reporter: Federico Grilli Assignee: Federico Grilli
Resolution: Done Votes: 1
Labels: foundation_team, java11
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
relation
is related to BUILD-433 Change Clover for open source and upd... Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
BUILD-706 Provide JaCoCo Maven plugin to builds Sub-task Closed Federico Grilli  
BUILD-707 Adjust code coverage in few selected... Sub-task Closed Federico Grilli  
BUILD-708 Adjust pipeline templates to select e... Sub-task Closed Federico Grilli  
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Date of First Response:

 Description   

Building with Java 11 fails due to Clover in our parent poms:

[ERROR] Failed to execute goal org.openclover:clover-maven-plugin:4.4.1:instrumentInternal (instrument-and-check) on project magnolia-cloud-maven-plugin: Unsupported Java language level version [11]. Valid values are [1.3], [1.4], [1.5], [1.6], [1.7], [1.8] and [1.9]/[9] -> [Help 1]

We currently use version 4.4.1 https://git.magnolia-cms.com/projects/BUILD/repos/poms/browse/poms/super-pom/pom.xml#136.
Looking here  https://github.com/openclover/clover/issues/64 support for JDK11 is still missing.

We should remove Clover and find an alternative to it (seems to be a dead project anyway).
See also discussion in Slack https://magnolia-cms.slack.com/archives/CDF2T239Q/p1632482240124000

Eventually we chose JaCoCo, see also comment section
https://www.jacoco.org/jacoco/trunk/doc/index.html



 Comments   
Comment by Mikaël Geljić [ 24/Sep/21 ]

JaCoCo is a popular choice, and actively maintained:

  • Experimental support for Java 18 class files (GitHub #1198).

https://www.jacoco.org/jacoco/trunk/doc/changes.html

Comment by Federico Grilli [ 04/Mar/22 ]

Here is a brief summary about trying out JaCoCo. Looks like it is the best option out there at the moment. 

JaCoCo (Java Code Coverage)
===========================

GOOD

  • supports most recent JDKs (including 17)
  • code coverage metrics similar to Clover (lines, branches, methods, classes, complexity)
  • instruments classes (like Clover) before running checks
    • adds "probes" to bytecode
    • needs source to be compiled with -debug option (Magnolia does it already)
    • minimal overhead (no different from Clover)
  • HTML reports (can be also aggregated by project, I think) embeddable in Maven sites
  • data consumable by SonarQube
  • we can still support Clover as long as needed

NOT SO GOOD

  • actual results vary slightly from Clover (apparently yield slightly less coverage)
    • need to re-adjust coverage percentages over several projects

HOW TO PROCEED (proposal)

  • create -Penable-jacoco (or something) profile in ppom 
  • replace cloverCoverageThreshold property with something more tech agnostic ("coverageThreshold"?)
  • start by adjusting coverages in few selected projects
  • adjust pipeline templates to select either Jacoco or Clover profile
Generated at Sun Feb 11 23:42:50 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.