添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
AI-Enhanced, Sonar Assured: Boost Developer Productivity and Improve Code Security in your SDLC - October 16 Register Now

Our maven project is organized as follows.
application/module*/src/main/java
environment/env1/pom.xml
environment/env1/module*/pom.xml
environment/env2/module*/pom.xml
where each pom.xml contains a sourceDirectory element similar to
…/…/application/module*/src/main

When we execute sonar:sonar the plugin ignores all of our source files with warnings like
[WARNING] File maven-unconventional/source/module1/src/main/java/com/acme/module1/Module1.java’ is ignored. It is not located in project basedir ‘maven-unconventional/maven’.

We’ve attempted to work around these issues by setting the sonar.projectBaseDir, sonar.sources, and source.tests properties. However, we’ve yet to see any source files in our SonarQube project.

We’ve created an example project, maven-unconventional, demonstrating this issue based on the maven-multimodule example in the sonar-scanner-examples.git repository which we would be happy to share.

Just adding additional information. The following output came from running the scanner on our application. In the first few lines we see that [Sonar] Base dir has been set to …/application/all.
In the following lines, we see warnings that our source files are being excluded because they’re not found within maven’s base directory (…/environment/cloud).

[DEBUG] 20:44:03.013 loading config FileBasedConfig[/var/lib/jenkins/.gitconfig]
[DEBUG] 20:44:03.105 8 non excluded files in this Git repository
[INFO] 20:44:03.108 Indexing files of module ‘XpAnalytics’
[INFO] 20:44:03.109 Base dir: /var/lib/jenkins/sharedspace/XpAnalytics/application/all
[DEBUG] 20:44:03.111 Source paths: src/main
[DEBUG] 20:44:03.111 Test paths: src/test
[WARNING] 20:44:03.113 File ‘/var/lib/jenkins/sharedspace/XpAnalytics/application/all/src/main/resources/META-INF/MANIFEST.MF’ is ignored. It is not located in project basedir ‘/var/lib/jenkins/sharedspace/XpAnalytics/environments/cloud’.
[WARNING] 20:44:03.113 File ‘/var/lib/jenkins/sharedspace/XpAnalytics/application/all/src/main/content/META-INF/vault/filter.xml’ is ignored. It is not located in project basedir ‘/var/lib/jenkins/sharedspace/XpAnalytics/environments/cloud’.
[WARNING] 20:44:03.114 File ‘/var/lib/jenkins/sharedspace/XpAnalytics/application/all/src/test/resources/placeholder.txt’ is ignored. It is not located in project basedir ‘/var/lib/jenkins/sharedspace/XpAnalytics/environments/cloud’.
[WARNING] 20:44:03.114 File ‘/var/lib/jenkins/sharedspace/XpAnalytics/application/all/src/test/java/placeholder.txt’ is ignored. It is not located in project basedir ‘/var/lib/jenkins/sharedspace/XpAnalytics/environments/cloud’.

I’ve created a example of this issue derived from the maven-multimodule example in sonar-scanning-examples. You can download it from here .

When you run this test it will complete without error. You need to run it with logging enabled (-X) then look for the warning messages reporting that the source files were excluded from the scan.