我想扩展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> …Run Code Online (Sandbox Code Playgroud)