[Maven SonarQube plugin] Adding the resource directories to the source and test path

2,347 views
Skip to first unread message

dfl...@objectif-informatique.fr

unread,
Jul 27, 2015, 8:47:36 AM7/27/15
to SonarQube
Hi,

I am launching a SonarQube analysis with Maven.
I would like to analyze the configuration files (java properties and Xml files) in the resources directory with the sonar-jproperties plugin and with a custom plugin with XML rules

Currently, I need to declare the 'sonar.sources' and 'sonar.tests' properties to add these directories.
I would prefer that by default, the Maven SonarQube plugin add the resource directories to the source and test path.

Regards,

Denis

Julien HENRY

unread,
Jul 27, 2015, 9:35:47 AM7/27/15
to SonarQube, dfl...@objectif-informatique.fr, dfl...@objectif-informatique.fr
Hi Denis,

I already though about this improvement. But I also have another option in mind: in Maven convention everything is source (including pom.xml). Only target folder may contains results of the build. So maybe we can simply make the SQ Maven plugin do:
  - sonar.sources=.
  - sonar.tests=.
  - sonar.tests.inclusions=src/test/**/*
  - sonar.exclusions=target/**/*

As a result it would allow to support all source folders (src/main/script, src/main/groovy, ...) out of the box. What do you think of that?

++

Julien

David Racodon

unread,
Jul 27, 2015, 9:45:13 AM7/27/15
to SonarQube, dfl...@objectif-informatique.fr, julien...@sonarsource.com
+1

dfl...@objectif-informatique.fr

unread,
Jul 27, 2015, 11:02:46 AM7/27/15
to SonarQube, julien...@sonarsource.com
Hi,

I already tested this configuration with different projects and I got a maven build failure with the message :

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project ***: File [relative=***, abs=***] c
an't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files -> [Help 1]

My environment : SonarQube 4.5.2, sonar-java 3.1, sonar-javascript 2.3, sonar-css 1.1, sonar-web 2.3, Maven 3.2.5, sonar-maven-plugin 2.6
Maven projects with multiple directories : src/main/java, src/test/java, src/webapp

I need to use the following parameters to complete the analysis:
 -Dsonar.sources=. -Dsonar.tests.inclusions=src/test/**/* -Dsonar.exclusions=**/test/**/*

Regards,

Denis

Julien HENRY

unread,
Jul 27, 2015, 11:21:28 AM7/27/15
to dfl...@objectif-informatique.fr, SonarQube
Yep, I just relied on the fact that recent SQ versions are automatically adding sonar.tests.inclusions to sonar.exclusions.

dfl...@objectif-informatique.fr

unread,
Jul 28, 2015, 5:23:00 AM7/28/15
to SonarQube, julien...@sonarsource.com
+1

for the proposal :

  - sonar.sources=.
  - sonar.tests=.
  - sonar.tests.inclusions=src/test/**/*
  - sonar.exclusions=target/**/*

Regards,

Denis

Julien HENRY

unread,
Jul 30, 2015, 10:19:58 AM7/30/15
to SonarQube, dfl...@objectif-informatique.fr, dfl...@objectif-informatique.fr

Alix Lourme

unread,
Aug 5, 2015, 6:15:39 PM8/5/15
to SonarQube, dfl...@objectif-informatique.fr
Hi,

I'm waiting this feature with impatience, thanks for MSONAR-123.

Two points :
1° This topic doesn't explicit the testResources maven configuration : considered as source (for XML / Properties / ... plugins) ? IMO yes
2° Like war plugin, maven-failsafe-plugin configuration could be analysed ? If I put my IT tests in "${baseDir}/tests-it" (with failsafe config override), considered these file as test could be great

Best regards
Reply all
Reply to author
Forward
0 new messages