Single Command to run sonar analysis for Java and Python

(Abhirup Chatterjee) #1

Hi,

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
sonar-scanner
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

Hi,

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.
see https://docs.sonarqube.org/latest/analysis/analysis-parameters/

Regards,
Gilbert

(Alexandre Gigleux) #3

Hello,

@abhirupchatterjee It’s always good to share scan logs, pom.xml and/or sonar-project.properties 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.