由sonar 進行 質量管控。css
其中junit 測試用例顯得比較重要, 下面是由sonar maven 集成的代碼覆蓋率html
下面的配置是多模塊配置,java
<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中的配置前後端分離
若是 你想要過濾某一個項目那麼你就要在這個子項目中配置maven
<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>