Mvn sonar:sonar doesn't scan angular files

Hi,

Sonarqube Enterprise 9.5, sonar-maven-plugin:3.9.1.2184, Maven 3.8.1

The Maven build uses the frontend-maven-plugin to build frontend and backend.

Source tree

+---src
+---main
|   +---java
|   [...]
|   +---liberty
|   |   \---config
|   +---ngapp
|    [...]
|   |   +---resources
|   |   \---example
|   \---webapp
|       \---WEB-INF
\---test
    +---java
    [...]
    \---resources

Plugin config

<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
    <workingDirectory>src/main/ngapp</workingDirectory>
    <nodeVersion>v14.17.0</nodeVersion>
    <npmVersion>7.16.0</npmVersion>
    <npmDownloadRoot>${npm.repository}</npmDownloadRoot>
    <nodeDownloadRoot>${node.repository}</nodeDownloadRoot>
    <npmRegistryURL>${npm.registry}</npmRegistryURL>
    <serverId>nexus</serverId>
</configuration>

The scanner context has only

sonar.sources=E:\Jenkins\workspace\foobar\src\main\webapp,E:\Jenkins\workspace\foobar\pom.xml,E:\Jenkins\workspace\foobar\src\main\java

AFAIK it should also automatically include src/main/ngapp and scan the *.ts, *.css, *.scss, *.html files without further configuration in pom.xml !?

Gilbert

Hey Gilbert.

Since sonar.sources defaults to pom.xml,src/main/java – if other directories are already being analyzed (like src\main\webapp), I suspect that somewhere you are defining sonar.sources to include those other directories and need to include the new one as well.

Hey Colin,

we didn’t set any sonar.sources, means those are set default.

sonar.sources=E:\Jenkins\workspace\foobar\src\main\webapp,E:\Jenkins\workspace\foobar\pom.xml,E:\Jenkins\workspace\foobar\src\main\java

It seems the Sonarqube Maven plugin is simply oriented to the Maven standard directory layout, see
https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

So in our case we had to use <sonar.sources>src/main</sonar.sources> to target all files
'(*.java, *.ts, *.css, *.scss, .html,.xml)

IMO the Sonar Maven plugin should use src/main as default value for sonar.source and not
consider only the default Maven directory layout.

Gilbert

Thanks for the feedback @Rebse. I’ll try and find the best folks to answer why we target src/main/java instead of src/main, and whether or not it’s reasonable to expand the scope.

Hello @Rebse,

Thanks for your message. I think that happened when a scanner for maven was implemented, the idea was to use it just for Java projects. Now it makes more sense to be able to scan other projects too. So here is a ticket to improve it:

https://sonarsource.atlassian.net/browse/MSONAR-190

Regards,
Margarita

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.