由sonar 进行 质量管控。
其中junit 测试用例显得比较重要, 下面是由sonar maven 集成的代码覆盖率
下面的配置是多模块配置,
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<sonar.language>java</sonar.language>
<sonar.exclusions>*.js,*.css,</sonar.exclusions>
</properties>
设置sonar扫描的语言,多个话 可能是以逗号分隔(这儿不是骗你, 我还真的没试过, 项目的前后端分离的)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
</formats>
<aggregate>true</aggregate>
<instrumentation>
<excludes>
<exclude>**/vo/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>check</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
这是在父项目的pom.xml中的配置
如果 你想要过滤某一个项目那么你就要在这个子项目中配置
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>check</goal>
<goal>cobertura</goal>
<goal>dump-datafile</goal>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>