简体   繁体   English

pom.xml中的<sonar.exclusions>(Maven多模块项目)在本地工作,但不在公司服务器上工作

[英]<sonar.exclusions> in pom.xml (Maven multi-module project) works locally but not on company server

I'm using <sonar.exclusions> in pom.xml to exclude certain packages for unit test code coverage. 我在pom.xml中使用<sonar.exclusions>来排除单元测试代码覆盖率的某些包。 I have set up Sonar locally and the exclusions reflect on the report. 我在当地设置了Sonar,排除项反映在报告上。 But then, the same exclusions are not honored on the company server. 但是,公司服务器上的相同排除项不受尊重。

I am using <sonar.skippedModules> which works as intended and skips the required modules perfectly fine on both environments. 我正在使用<sonar.skippedModules>按预期工作,并在两个环境中完全跳过所需的模块。

Local Sonar version is Version 4.3.1 Company's Sonar version is Version 4.1.2 本地Sonar版本是版本4.3.1公司的Sonar版本是版本4.1.2

An example of how I have written <sonar.skippedModules> in one of the modules: 我在其中一个模块中编写<sonar.skippedModules>的示例:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.mainClass>.....</project.mainClass>
    <sonar.exclusions>
        /src/main/java/../../../../../Package1/*,
        /src/main/java/../../../../../Package2/*,
        /src/main/java/../../../../../JavaClass1.java
    </sonar.exclusions>
    <sonar.language>java</sonar.language>
</properties>

Can you please help me understand why <sonar.exclusions> is honored only locally but not when I build the job (set up on Jenkins) to generate the Sonar report on the company server? 您能帮助我理解为什么<sonar.exclusions>仅在本地获得荣誉,但在我建立工作(在Jenkins上设置)以在公司服务器上生成Sonar报告<sonar.exclusions>没有? Does the difference in the version matter? 版本的区别是否重要?

Would absence of new-line character following the comma to separate the package names make a difference? 在逗号之后是否缺少用于分隔包名称的新行字符会有所不同吗?

Try this, I had same issue and it worked for me 试试这个,我有同样的问题,它对我有用

Don't start with " /src/main/java/ " Instead start with " com/companyname/projectname/ " 不要以“ /src/main/java/ ”开头而是以“ com/companyname/projectname/com/companyname/projectname/

I personally prefer " **com/companyname/projectname/../** " 我个人更喜欢“ **com/companyname/projectname/../**

我可能会弄错,但你应该删除sonar.exclusions开头的/字符,让它们相对于项目的根目录进行计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM