We are using Sonarqube on our server and when we are triggering build of maven from TFS (Azure Devops) using the CI yaml pipeline.
Sonarqube step is having exclusion but it fails to exclude the class and issue occurs of Jacoco ant exception.
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 …… @ 8:11 in /buildagent/_work/2/s/com.avl.data/target/antrun/build-main.xml: Error while analyzing messagebroker-consumer-app/target/messagebroker-consumer-app-1.0-SNAPSHOT.jar@BOOT-INF/lib/zookeeper-3.4.14.jar@org/apache/jute/BinaryInputArchive$BinaryIndex.class. Can’t add different class with same name: org/apache/jute/BinaryInputArchive$BinaryIndex
Yes we have multiple classes in the project, but i am not able to find them as it says some build class error
/buildagent/_work/2/s/com.avl.data/target/antrun/build-main.xml: Error while analyzing messagebroker-consumer-app/target/messagebroker-consumer-app-1.0-SNAPSHOT.jar@BOOT-INF/lib/zookeeper-3.4.14.jar@org/apache/jute/BinaryInputArchive$BinaryIndex.class. Can’t add different class with same name: org/apache/jute/BinaryInputArchive$BinaryIndex
We are using maven and then ant is utilised from it.
Whether or not you have multiple classes in the project was not the question; my assumption was that you did. The error says you have multiple classes with the same name. Is that the case?
As for how you’re performing analysis, there’s no good reason to call the Ant analyzer from Maven. If you have a Maven project, then perform a Maven analysis (mvn sonar:sonar). If you don’t have a Maven project, then just use the CLI SonarScanner (or perhaps you have a Gradle project?) And if you actually have an Ant project, well… I’d exec the CLI SonarScanner from your Ant file.
Yes your assumption is right, i am not able to find that project’s folder which needs to be excluded here and name are same somehow as per error for the class.
And we are performing maven build, sonarscanning and jacoco scans using TFS (azure devops).
And as per error it is maven integrate project.
Not gradle.
As in our maven build locally, there comes a folder for the maven dependency and when i am building the same with the Azure Devops, this folder is not build and somehow i need to find out which target folder or directory to add into exclusion of sonar.coverage.exclusion.
I would start by excluding everything, using a list of directories. Analyze that & make sure it works. Then you can slowly delete from the list to add things back in.
Generally, I recommend setting exclusions through the UI. But okay.
First, there’s no reason to set the path from box root. in fact, that’s probably why your exclusions aren’t kicking in; they’re assumed to start from project root. Second, you’ve set an exclusion on directories ("**"), not files. Not sure that will work.
To exclude everything, try this:
sonar.coverage.exclusions=**/*.*
Alternately, to do it in a format that will later make it easy to subtract from:
[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 …… @ 8:11 in /buildagent/_work/1/s/com.avl.data/target/antrun/build-main.xml: Error while analyzing messagebroker-consumer-app/target/messagebroker-consumer-app-1.0-SNAPSHOT.jar@BOOT-INF/lib/zookeeper-3.4.14.jar@org/apache/jute/BinaryInputArchive$BinaryIndex.class. Can’t add different class with same name: org/apache/jute/BinaryInputArchive$BinaryIndex
[ERROR] -> [Help 1]
Still there is error after using the all exclusion.
sonar.coverage.exclusions=**/.