Please provide compiled classes of your project with sonar.java.binaries
Solution 1:
You're running your Maven steps in the wrong order:
-
clean
- delete all previous build output -
sonar:sonar
- run analysis (which requires build output) -
deploy
- build &etc...
Try this instead:
mvn clean deploy sonar:sonar
Now if you're about to object that you don't want to actually "deploy" the jar until/unless the changed code passes the Quality Gate, well... that requires a different workflow:
mvn clean package sonar:sonar
// check quality gate status
// if (qualityGateOk) { deploy }
The particulars of those last two steps will depend on your CI infrastructure. But for Jenkins, step #2 is well documented
Solution 2:
I got the same error while invoking Standalone SonarQube Analysis as a Jenkins job pre-build step, which I fixed adding sonar.java.binaries=**/target/classes
along with other SonarQube Analysis properties, as follows:
sonar.projectKey=TEST-PROJECT
sonar.projectName=TEST-PROJECT
sonar.projectVersion=1.0
sonar.sources=src/main/java/
sonar.language=java
sonar.java.binaries=**/target/classes
Solution 3:
I had a seme problem. I did below steps Added Invoke top-level maven target from build steps (It should be the first build step) added clean install.
and also added below properties to my Analysis properties under Execute SonarQube scanner.
sonar.projectVersion=1.0
sonar.sources=src/main/java
sonar.sourceEncoding=UTF-8
sonar.language=java
sonar.java.binaries=target/classes
Solution 4:
For Java, the binaries are in the target folder. That's why you should use mvn clean install sonar:sonar
to make sure your project is compiled and inside the target folder.
Sonar scans your binary classes.