I got the error message Error during SonarScanner execution org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
but there are no binaries files in my source code.
Compiled .class files are required for java projects with more than one java file. If not provided properly, analysis will fail with the message:
Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
The Sonarqube scan usually runs after compilation as part of your build pipeline in Jenkins or similar.
Just point your sonar.java.binaries to the right direction and you’re done.
With Maven and the Sonarqube Maven plugin it’s a piece of cake, it just works.
see SonarScanner for Maven
The message shows that I can exclude the java binaries from the analysis with sonar.exclusions property, but it doesn’t work. Have you had any idea about this?
Sorry, but I do not understand what you mean !? What message ?
The sonar.java.binaries property is mandatory.
There are hacks like sonar.java.binaries=. but it doesn’t make sense.
Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
They said that I can use the sonar.java.binaries or sonar.exclusions.
If SonarQube’s results aren’t relevant, no one will want to use it. That’s why precisely configuring what to analyze for each project is a very important step. Doing so allows you to remove noise, like the issues and duplications marked on generated code, or the issues from rules that aren’t relevant for certain types of files.
What i meant to say
If it is a java project, it doesn’t make sense to exclude java files or use tricks like sonar.java.binaries=. as the Sonar Java scanner needs the binaries for precise results.
Whereas if it’s a project with another main language, that has also java files that are not relevant,
you might use sonar.exclusions = **/*.java to exclude all java files.
This will also prevent
Your project contains .java files, please provide compiled classes with sonar.java.binaries property