问题
I'm running sonar-5.1.2 with Maven / Jenkins CI.
After googling and looking through similar questions (most of them are dated back to 2010-2012), it is still not clear how to exclude a particular Maven module from multi-module Maven project.
Module Exclusions property is deprecated since version 4.3 and should not be used anymore.
We have duplicating packages in different modules:
root pom.xml
|-module1
|-my.package.com
|-module2
|-my.package.com
Is it possible to exclude only files from module2/my.package.com but include module1/my.package.com?
SonarQube analysis is triggered by https://wiki.jenkins-ci.org/display/JENKINS/SonarQube+plugin post build action
回答1:
There are two documented options to exclude a module from a SonarQube analysis; quoting:
You can either:
- use build profiles to exclude some module (like for integration tests)
- use Advanced Reactor Options (such as "-pl"). For example mvn sonar:sonar -pl !module2
Since you are using Jenkins, maybe the simpler solution is to use the -pl option. This way, you won't change any configuration in your Maven project and you will only change Jenkins configuration.
回答2:
Remove module2 in your root pom.xml.
<modules>
<module>module1<module>
</modules>
回答3:
As documented here you can define property
<sonar.skip>true</sonar.skip>
in the pom.xml of the module you want to exclude
来源:https://stackoverflow.com/questions/33080131/sonarqube-exclude-maven-module