I realize there are several similar issues out there, but none of the solutions work for me. I'm building a Spring Boot Java service in an Azure pipeline.
- task: Maven@3
displayName: 'Build'
inputs:
mavenPomFile: 'pom.xml'
goals: 'clean org.jacoco:jacoco-maven-plugin:report package'
publishJUnitResults: true
codeCoverageToolOption: jacoco
testResultsFiles: '**/surefire-reports/TEST-*.xml'
I'm getting the following error as I run the build
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (default) on project VstsReport: An Ant BuildException has occured: Error while creating report
[ERROR] around Ant part ...<report>... @ 8:11 in /home/vsts/work/1/s/myApp/target/antrun/build-main.xml: Error while analyzing apiservice/target/apiservice-0.0.1-SNAPSHOT.jar@BOOT-INF/lib/log4j-api-2.13.3.jar@org/apache/logging/log4j/util/ProcessIdUtil.class. Can't add different class with same name: org/apache/logging/log4j/util/ProcessIdUtil
I'm attempting to Exclude, but no matter what I put in the Exclude tag, nothing is working. The exclude below do not work. I have tried all permutations I can think of. Even this:
<exclude>**/*.*</exclude>
does absolutely nothing. I must be doing something else wrong.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<configuration>
<excludes>
<exclude>../apiservice-0.0.1-SNAPSHOT.jar</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
The plugin seems to acknowledge the exclude statements as they are represented in the log output below.
[INFO] --- jacoco-maven-plugin:0.8.4:prepare-agent (default-prepare-agent-vsts) @ apiservice --- [INFO] argLine set to -javaagent:/home/vsts/.m2/repository/org/jacoco/org.jacoco.agent/0.8.4/org.jacoco.agent-0.8.4-runtime.jar=destfile=/home/vsts/work/1/s/rulesengine/CCReport43F6D5EF/jacoco.exec,includes=**/*,excludes=../apiservice-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- jacoco-maven-plugin:0.8.4:prepare-agent (prepare-agent) @ apiservice --- [INFO] argLine set to -javaagent:/home/vsts/.m2/repository/org/jacoco/org.jacoco.agent/0.8.4/org.jacoco.agent-0.8.4-runtime.jar=destfile=/home/vsts/work/1/s/rulesengine/CCReport43F6D5EF/jacoco.exec,excludes=../apiservice-0.0.1-SNAPSHOT.jar
UPDATE: Removing
codeCoverageToolOption: jacoco
from the Maven@3 task resolved all the problems. I don't know the purpose of that setting or why it completely overrides any setting in the pom.xml. I'm leaving this post here in case someone finds it useful.