vbo*_*ers 12 java maven sonarqube
我想扩展sonar.sources,默认情况下pom.xml,src/main/java,是src/main/resources为了检查位于那里的XML文件.
这个看似简单的任务变得很困难,因为我有一个多模块maven项目(> 100个模块,嵌套),其中很多没有src/main/resources文件夹,大多数甚至没有src文件夹(例如for packaging = pom) ).如果我设置sonar.sources为pom.xml,src/main/java,src/main/resources或,这会导致构建错误pom.xml,src/main:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project xyz-parent: The directory 'C:\...\submodule\src\main\resources' does not exist for Maven module ... Please check the property sonar.sources -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
sonar-maven-plugin本身用于${project.build.sourceDirectory}在每个模块中正确执行.
我试图用正则表达式来设置sonar.sources,以src/main通过切断/java(或\java通过在Windows上)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>sonar.sources</name>
<value>${project.build.sourceDirectory}</value>
<regex>[/\\]+java$</regex>
<replacement></replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但这没有任何作用,我不知道我应该将它绑定到哪个生命周期阶段才能执行它.
或者有没有办法避免由于缺少目录而导致的错误sonar.sources?根据当前的声纳maven源缺失目录只有在POM有pom包装但没有资源ear或jar没有资源的模块时才会被忽略.
或者我应该确保src/main在声纳开始之前存在?我可以使用什么钩子?
Fab*_*eam 20
你可以做的一件事:
sonar.sources 成为 .sonar.inclusions 成为 src/main/**src/main文件夹中的模块中找到的所有已知文件(如果存在)sonar.exclusions或sonar.inclusions