codeclimate / test-reporter

Code Climate Test Reporter
MIT License
154 stars 76 forks source link

Add support for Jacoco report output using the report-aggregate goal in a Maven multi-module project #376

Open io-timeout opened 5 years ago

io-timeout commented 5 years ago

When working with JaCoCo in a maven multi-module project it is necessary to use the report-aggregate goal to create an aggregated test coverage report.

The format of the jacoco.xml file in this case is a little different to the version produced when using the report goal as JaCoCo outputs an additional <group name="api-common"> element as the parent of the <package> element which the coverage formatter is expecting. The purpose of the<group>element is to state which module contains the code described by the child elements of the group.

A sample project using the report-aggregate goal can be found here: https://github.com/DEFRA/data-returns-api-platform

As a workaround I was able to strip <group> elements from the xml file before running cc-reporter as follows:

sed -e 's/<[\/]\?group[^>]*>//g' target/site/jacoco-aggregate/jacoco.xml > target/site/jacoco-aggregate/jacoco-codeclimatecompat.xml
JACOCO_SOURCE_PATH="api-common/src/main/java api-example/src/main/java" ./cc-test-reporter format-coverage target/site/jacoco-aggregate/jacoco-codeclimatecompat.xml --input-type jacoco
./cc-test-reporter upload-coverage

It would be nice (in the short term) if the codeclimate reporter could just ignore <group> elements as allowing multiple items in the JACOCO_SOURCE_PATH env-var means this would work quite nicely. In the longer term the reporter could potentially use the content of the <group> element to auto-discover the correct source paths to use.

FranziskusW commented 4 years ago

+1 (although a gradle android project)

Any news here?

aledevops commented 2 years ago

+1

kbirger commented 10 months ago

+100