SONAR - 如何排除在“sonar.test"下定义的包; [英] SONAR - How to exclude packages that is defined under "sonar.test"
问题描述
我在 JAVA 中有一个项目,我使用声纳进行分析.我拥有的一些 java 包都在源文件夹下.我还有一些测试文件,我在不同的文件夹下.现在,在声纳中,我在不同的结构下组织我的项目,即对于项目搜索",我只想包含搜索"包.使用 sonar.exclusion 属性很容易完成这些排除.不过,我的问题是测试怎么样?我怎样才能排除一些包?因为从我的测试来看,即使我的源和测试文件夹使用相同的结构,当我指定sonar.exclusions"时,测试包并不会自动排除.
I have a projects in JAVA that I analyze using sonar. Some of the java packages that I have are all under source folder. I also have some test file that I have under a different folders. Now, in Sonar, I organize my projects under a different structure, i.e. for a project "search", I only wants to include "search" package. These exclusion is quite easy to accomplished using sonar.exclusion properties. My question, though, is how about the test? how can I exclude some of the packages? Because from my testing, even though my source and test folder are using the same structure, the test packages are not automatically excluded when I specified "sonar.exclusions".
我的文件夹结构:
/src/com/domain/
-- search/
-- utils/
-- pooling/
-- category/
/test/src/com/domain/
-- utils/
-- pooling/
声纳属性:
<property name="sonar.sources" value="${path}/src" />
<property name="sonar.tests" value="${path}/test/src" />
<property name="sonar.exclusions" value="com/domain/utils/**/*,com/domain/pooling/**/*,com/domain/category/**/*" />
所以,我试图只包含搜索"包.上面的代码的工作方式是使 SONAR 只分析我的搜索"包.这个包可以在 SONAR 的组件"选项卡中看到.不幸的是,除了搜索"组件,我还可以看到util"和pooling"组件.我已经做了一些测试并且确定这两个组件(utils 和 pooling)是sonar.tests"属性的结果.不过请注意,即使util"和pooling"出现在组件中,SONAR 在它们下都显示零个文件.所以回到我的问题,无论如何我可以做些什么来排除util"和pooling"出现在组件"下?也许使用属性(即声纳测试排除)?
So, I am trying to only include the "search" package. The code above works in a way that it causes SONAR to only analyze my "search" package. This package can be seen in the SONAR "Components" tab. Unfortunately, in addition to the "search" component, I can also see the "util" and "pooling" components. I have done some testing and certain that these two components (utils and pooling) are the result of "sonar.tests" properties. Just a note though, even though "util" and "pooling" shows up in components, SONAR shows zero files under both of them. So going back to my question, is there anyway that I can do to exclude "util" and "pooling" from showing up under "Components"? Maybe using properties (i.e. sonar test exclusions)?
顺便说一句,我使用的是 SONAR 2.11 并在 Red Hat linux 下运行.我使用的是 SONAR-TASK 1.2.
Btw, I am using SONAR 2.11 and is running under Red Hat linux. I'm using SONAR-TASK 1.2.
欢迎并感谢任何帮助!谢谢!
Any help is welcomed and appreciated! Thanks!
推荐答案
您可以直接在声纳中为项目在配置中定义排除项.
You can define exclusions in the Configurations for the project directly in sonar.
这篇关于SONAR - 如何排除在“sonar.test"下定义的包;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!