AEM Cloud Build pipeline fails due to Code Scanner (Jacoco) plugin version does not support Multi-Release Jars
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.20250304T101418Z) build 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?