4

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?

4
  • is coverlet a alternative for you? I made good experience and it is original made for java. Commented Jan 6, 2020 at 13:35
  • 1
    @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. Commented Jan 6, 2020 at 15:00
  • 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? Commented Jan 7, 2020 at 7:41
  • I highly doubt that an abandoned tool from 2003 came up often in 2020. For context, Java 8 (used in the question) was released in 2014. Commented Jul 31, 2024 at 3:54

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.