我想擴展sonar.sources
,默認爲pom.xml,src/main/java
,用src/main/resources
來檢查位於那裏的XML文件。sonar-maven-plugin:在多模塊項目中擴展sonar.sources
這個看似簡單的任務竟然是困難的,因爲我有一個多模塊Maven項目(> 100個模塊,嵌套),與他們中的很多沒有src/main/resources
文件夾,其中大部分甚至沒有src
文件夾(例如,對於包裝= 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]
的聲納Maven的插件本身使用${project.build.sourceDirectory}
做每個模塊權利英寸
我試圖通過切斷(在Windows或\java
)/java
通過
<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>
使用正則表達式來設置sonar.sources
到src/main
但是這並沒有什麼,我不知道哪個生命週期階段,我應該將它綁定讓它執行。
或者有沒有辦法避免由於缺少目錄sonar.sources
中的錯誤?根據current sonar-maven source如果POM有pom
包裝但沒有ear
或jar
模塊沒有資源,則只會忽略缺少的目錄。
或者我應該確保src/main
在聲吶啓動之前存在?我可以使用什麼鉤子?
謝謝!我已經將'sonar.inclusions'設置爲'pom.xml,src/main/**',它的工作方式應該是它應該的。我認爲這會改進[documentation](http://docs.sonarqube .org/display/SONAR/Analysis + Parameters)如果'sonar.exclusions'不僅在[Narrowing the Focus]中討論(http://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus )。 – vboerchers