sonar maven analysis only picks .java file

4.6k Views Asked by At

I am trying to run a sonar maven analysis on my multilanguage project which contains many languages like *.java, *.groovy, *.js etc. I have installed all the languages plugin in my sonar and configured my pom sonar.sources parameter as src/main,src/test but still it picks up only java files. In the console output. I get the following lines in the console indicating that it only scans the folders with pattern src/main/java and src/test/java

[INFO] [05:13:57.140] -------------  Scan myapp
[INFO] [05:13:57.140] Load module settings
[INFO] [05:13:57.187] Initializer FindbugsMavenInitializer
[INFO] [05:13:57.187] Initializer FindbugsMavenInitializer (done) | time=0ms
[INFO] [05:13:57.187] Base dir: C:\myapp
[INFO] [05:13:57.187] Working dir: C:\myapp\target\sonar
[INFO] [05:13:57.187] Source paths: pom.xml, src/main/java
[INFO] [05:13:57.187] Test paths: src/test/java

I am currently using SonarQube 5.1, Java 7u80

Note: If analysis is done using Sonar Runner, It scans all the files.

2

There are 2 best solutions below

1
On BEST ANSWER

Since it was a multi module project, I had to include the properties sonar.sources and sonar.tests in the parent module's pom.xml file.

<properties>
    <sonar.sources>pom.xml,src/main,src/test</sonar.sources>
    <sonar.tests></sonar.tests>
</properties>

sonar.tests parameter is empty since it is incompatible with Maven.

3
On

Since SonarQube 4.2, it is possible to run an analysis on a multi-language project. To do so, the sonar.language property just has to be removed. Conversely, if for some reason you want to perform a single language-only analysis, make sure sonar.language is specified.

By default the sonar.sources property is set to the value of the Maven sourceDirectory property (by default it is src/main/java) plus pom.xml (and also src/main/webapp is automatically added for war modules). Therefore, for a multi-language project, the property usually has to be overridden to: sonar.sources=src/main,pom.xml.