3

We have a multi-module maven project. We are using java8.

-Parent
-- Child 1
-- Child 2
-- Coverage-Report

All projects have unit test cases, those all are working good and have more than 85% of coverage. Parent pom.xml file has jacoco-profile and jacoco-maven-plugin plugin as below

      <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.6</version>
            <configuration>
                <destFile>${sonar.coverage.jacoco.xmlReportPaths}</destFile>
                <append>true</append>
            </configuration>
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

In Coverage-Report module, there is only pom.xml which is for aggregating report. It has profile as jacoco as below

    <profile>
        <id>jacoco</id>
        <activation/>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>report-aggregate</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report-aggregate</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

To generate the report, we are using below command

mvn clean verify -Pjacoco

We do see the file getting generated which is mentioned in parent pom.xml

<sonar.coverage.jacoco.xmlReportPaths>${maven.multiModuleProjectDirectory}/ocapi-promotion-service-coverage-report/target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    

However this file, jacoco.xml, is not proper XML. It has some encoded character as below. (few lines from that file)

��ca6191af5ae0-1a24a201}-�Sy}-ƌ|pW�\����;org/springframework/context/annotation/BeanAnnotationHelper�w~�j�zI�ZMorg/springframework/boot/autoconfigure/condition/FilteringSpringBootCondition������e֢+org/sp

On jenkins we see below error

Caused by: java.nio.charset.MalformedInputException: Input length = 1

I have followed an article from sonar source community https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151 which gives some steps. But I am not able to generate XML file. Please help.

MFerguson
  • 1,739
  • 9
  • 17
  • 30
Vikrant Korde
  • 315
  • 2
  • 11

0 Answers0