I am getting following error while running a test project in Jenkins
Caused by: java.lang.LinkageError: loader 'bootstrap' attempted duplicate class definition for java.lang.$JaCoCo. (java.lang.$JaCoCo is in module java.base of loader 'bootstrap')
Jacoco is defined in the parent pom and the current test pom with different goals.
parent-pom.xml
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate-headless</id>
<phase>validate</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<skip>true</skip>
<propertyName>failsafe.argLine</propertyName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
test-project-pom.xml
<properties>
<maven.repo.local>${user.home}/.m2/repository</maven.repo.local>
<itCoverageAgent>-javaagent:${maven.repo.local}/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar=destfile=${basedir}/target/jacoco-it.exec</itCoverageAgent>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>${failsafe.argLine} ${itCoverageAgent}</argLine>
<testFailureIgnore>true</testFailureIgnore>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>coverage</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<id>prepare-agent-unit</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<propertyName>itCoverageAgent</propertyName>
</configuration>
</execution>
<execution>
<id>report-unit</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
If ${itCoverageAgent}
is removed from <argLine>
in test-project-pom.xml it works fine. How do we execute different goals from parent-pom and test-project-pom for the same version of Jacoco ?
<exclusions>
or<scope>
with plugins as they seems to be only supported withdependencies
? – Caddis