4
votes

In Azure Devops Maven build pipeline, while building multi-module java project, the build was successful.

However, the Jacoco code coverage is failing with below error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project VstsReport: An Ant BuildException has occured: Unable to read execution data file /vsts/agent/_work/8/s/CCReport43F6D5EF/jacoco.exec
2020-01-02T22:17:12.5100407Z [ERROR] around Ant part ...... @ 8:11 in /vsts/agent/_work/8/s/target/antrun/build-main.xml: /vsts/agent/_work/8/s/CCReport43F6D5EF/jacoco.exec (No such file or directory)

Azure pipeline yml file has the following task parameters:

task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
goals: 'package'
options: '--settings settings.xml'
codeCoverageToolOption: JaCoCo
codeCoverageSourceDirectories: epubcheck-service/src/main,epubcheck-service/src/test
codeCoverageClassFilesDirectories: epubcheck-service/target/classes,epubcheck-service/target/test-classes
sonarQubeRunAnalysis: true

If I comment the codeCoverage parameters then the Maven build task completes successfully. Only when I add the codeCoverage parameters on a multi-module project, I am getting the above-mentioned error.

Can somebody who used Azure DevOps pipeline for building Java maven build and Jacoco code coverage tool help me?

1
is coverlet a alternative for you? I made good experience and it is original made for java.Mar Tin
@MarTin Thank you for your response. I went through the documentation of Coverlet. It seems to be a .Net coverage tool. No reference is mentioned in the documentation for analyzing Java code. Please share if you have any reference to Java.Sheik Ahamed
you right, I got a little mixed up. So I can't realy recommand you something for java, but what I see often in the context code coverage for java is Quilt. Have you ever heard of it?Mar Tin

1 Answers

1
votes

Including jacoco-maven-plugin in the pom.xml of the parent project resolved it for us. Below is an excerpt:

<plugin>
    <groupId>org.sonarsource.scanner.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
</plugin> 
<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>