Findbugs(以及我知道的所有其他代码指标插件)会生成一个 XML 文件。我要做的是编写一个专门用于读取这些 xml 文件的 maven 插件。它会在某个地方保留一个私有查找表,它存储每个构建、每个指标的最后一个值。
它将使用一个通用的解析器接口,您必须为每个度量插件实现该接口。配置将是这样的:
<plugin>
<groupId>com.yourcompany</groupId>
<artifactId>your-plugin-id</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>readmetrics</id>
<phase>process-classes</phase>
<goals>
<goal>analyse-metrics</goal>
</goals>
</execution>
</executions>
<configuration>
<metrics>
<metric>
<type>findbugs</type>
<file>${project.reporting.outputDirectory}/findbugs/output.xml</file>
</metric>
<metric>
<type>checkstyle</type>
<file>${project.reporting.outputDirectory}/checkstyle/output.xml</file>
</metric>
<metric>
<type>pmd</type>
<file>${project.reporting.outputDirectory}/pmd/output.xml</file>
</metric>
</metrics>
</configuration>
</plugin>