SonarQube ignores files in Maven src/main/resources

Hi community,
I’m using the Maven scanner to analyze my project.
The directory layout of my project is standard:

    /src
        /main
            /java/com/package/MyClass.java
            /resources/sql/my-sql-file.sql
    pom.xml

The Java class and the pom.xml is detected and analyzed by SonarQube.
But the sql file is completely ignored.
Does someone know why?

I did not configure any exclusions.
SQL files in other projects (non-Maven) are analyzed successfully.

Versions:
SonarQube EE 8.1
sonar-maven-plugin: 3.7.0.1746
OpenJDK 11

Hi,

I believe Maven analysis is going to pick up only Java sources automatically & by default. If you need it to pick up something from resources, then I think you’ll need to override the sonar.sources value to include both subdirectories.

 
HTH,
Ann

2 Likes

The maven scanner also picks up other - non java - sources. We have projects that contain a
/src/main/webapp
directory, beside the Java code.
The scanner by default finds all CSS, HTML and JavaScript and analyzes it.
That’s why I wondered why *.sql is not taken into account.
I will try and add the “sources” parameter.
But it would be great if you could find out with your team, why some source-types (Java, HTML, CSS) are picked up by default and *.sql not.

Hi, Ann . Maven analysis is going to pick up only Java sources automatically , why src/resources not included

Hi @YorkHwang,

Welcome to the community!

Maven analysis doesn’t pick up src/resources because we rely on Maven to give us the project configuration. So when we say “Hey Maven, where are the source files?” Maven only gives us Java files by default.

 
HTH,
Ann

2 Likes

Given that, is there any chance to let Maven tell maven scanner that : “the sources files include src/main/java & src/main/resources” ?

Welcome :slight_smile:

Don’t hijack threads two years old, better create a new one :wink:

When using the latest version of the sonar-maven plugin = 3.10 the default sources include
is src/main, means src/main/resources should also automatically be included.

see this thread for further details

Gilbert

1 Like