Single Command to run sonar analysis for Java and Python

(Abhirup Chatterjee) #1


I am using SonarQube 7.7 version. I am looking for a single maven command to run sonar analysis with java and python.

My Current approach:

I am able to run sonar analysis with java using below command
mvn clean install sonar:sonar
Note: above command doesn’t analyse any python file.
And I am able to run python analysis with sonar with bellow command
Note: I have extracted the sonar-scanner-cli and set path for bin folder

I want to run sonar analysis with java and python using a single maven command. Can anyone help me on that ?

(Gilbert Rebhan) #2


calling the sonar goal will start analyzing your project. The scope is set via property sonar.sources and sonar.exclusions.
Depending on the languages in the source tree and the installed language scanner plugins on sonarqube server all detected files will be analyzed. If your source tree contains Java and Python sources that are not excluded by sonar.exclusions and your Sonarqube server has Sonar Java and Sonar Python installed they will be analyzed.


(Alexandre Gigleux) #3


@abhirupchatterjee It’s always good to share scan logs, pom.xml and/or so that experienced SonarQube users can identify what’s wrong in your configuration.

I confirm that out of the box, SonarScanner (aka SonarScanner CLI) or the “sonar:sonar” command scan all the languages you have in your project.

(Abhirup Chatterjee) #4

Hi Gilbert and Alexandre,
Thank you so much, I was able to run java and python both using the same maven profile. I have added 2 property in order to get python files analyzed, sonar.sources and sonar.language, where as for java and xmls we don’t need to set those two properties.