[sonar-scanner error] sonar.java.binaries property

Problem Summary

run sonar-scanner in my project root and get error “ERROR: Please provide compiled classes of your project with sonar.java.binaries property”

Steps to reproduce

step1

get sonarqube run in docker

docker run -d --name sonarqube -p 9000:9000 sonarqube

step2

create a token and get the sonars-canner run options

sonar-scanner \
  -Dsonar.projectKey=go_wallet \
  -Dsonar.sources=. \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=0fd1d50d096f308c8de1fb52fc68ab2a530db9b6

step3

cd to my golang project at $GOPATH/src/ and run the sonar-scanner with above option, got error

ERROR: Error during SonarQube Scanner execution
ERROR: Please provide compiled classes of your project with sonar.java.binaries property
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Env info

sonarqube version: 7.7.0.23042
sonarscanner version

shiming@pro ➜  wallet git:(master) ✗ sonar-scanner -v
INFO: Scanner configuration file: /Users/shiming/Downloads/sonar-scanner-3.3.0.1492-macosx/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Mac OS X 10.14.1 x86_64

Question

  1. What’s the error talk about? (I am not familiar with java, please explained in plain words )
  2. How can I solve it?

Hi,

For many languages you only need source code for analysis. For Java you need to feed in both source code and the compiled byte code. I’m guessing you’re not a project owner or contributed. You should consult those folks to find out how to compile the project. Once it’s compiled, you’ll then need to pass the location of the binary files into analysis.

If they use Maven for compile, then you can use SonarQube Scanner for Maven to run analysis and it handle most of the configuration - including the location of the binaries - for you. Ditto Gradle.

 
Ann

Hi, thanks for reply, I want to analysis golang program rather then java, in step3 I have mentioned that. So how can I run sonar scanner to analysis golang project successful? It keeps return error ERROR: Please provide compiled classes of your project with sonar.java.binaries property

Hi,

It wouldn’t be giving you that message if Java files weren’t found in the project. SonarQube analysis is multi-language and by default every file with a recognized extension is going to be analyzed. If you want to ignore files that end with .java you’ll need to set up an exclusion like **/*.java.

 
Ann