AEM Cloud Build pipeline fails due to Code Scanner (Jacoco) plugin version does not support Multi-Release Jars | Community
Skip to main content
Level 2
April 3, 2025
Solved

AEM Cloud Build pipeline fails due to Code Scanner (Jacoco) plugin version does not support Multi-Release Jars

  • April 3, 2025
  • 1 reply
  • 3950 views

Hello,

 

For our project we require a connection to be made to a SFTP server. We managed to get this to work locally, OSGI picks the newly included Jsch JAR and we where able to establish a SFTP connection and perform the required operations.

However, The AEMaaCS(2025.3.19823.20250304T101418Zbuild pipeline can build the project successfully, but the code scanner that runs after the build fails with the following error:

 

==================

[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.12:report (default-cli) on project palfinger.core: An error has occurred in JaCoCo report generation.: Error while creating report: Error while analyzing /build_root/build/palfingeragprogram-p152172-uk33244/core/target/classes/jsch-0.2.23.jar@META-INF/versions/9/com/jcraft/jsch/JavaVersion.class with JaCoCo 0.8.12.202403310830/dbfb6f2. Can't add different class with same name: com/jcraft/jsch/JavaVersion

==================

 

This is because JaCoCo which is used for Code scanning by Build Pipeline does not support the multi release jars so it finds duplicate classes as it scans all the classes of all included releases.

In this SatckOverflow thread, the accepted answer seems to provide the solution: https://stackoverflow.com/questions/47664723/jacoco-and-mr-jars

 

  • To give some background information, there are the changes we made to our project
  • Updated Java version to 17 (So we can update the BND plugin)
  • Updated bnd plugin to version 7.1.0 (so it supports Multi Release Jars)
  • Added Jsch Dependency in POM:

<dependency>

<groupId>com.github.mwiede</groupId>

<artifactId>jsch</artifactId>

<version>0.2.23</version>

</dependency>

  • Added the following to the BND Configuration section of the core pom: -includeresource: jsch-[0-9.]*.jar;lib:=true

Does anyone encountered similar issue and found the solution? 

Best answer by narendiran_ravi

You can exclude this jar from jacoco execution by adding -

<exclude>jsch-0.2.23.jar</exclude> 

in the jacoco plugin configuration of your pom.xml

<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <configuration> <excludes> <!-- Exclude jar --> <exclude>*.jar</exclude> </excludes> </configuration> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-site</id> <phase>package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>

 

1 reply

narendiran_ravi
narendiran_raviAccepted solution
Level 6
April 3, 2025

You can exclude this jar from jacoco execution by adding -

<exclude>jsch-0.2.23.jar</exclude> 

in the jacoco plugin configuration of your pom.xml

<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <configuration> <excludes> <!-- Exclude jar --> <exclude>*.jar</exclude> </excludes> </configuration> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-site</id> <phase>package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>

 

Level 2
April 4, 2025

@narendiran_ravi thanks a lot, marking this as accepted solution.