1.配置本地maven的settings.xml的maven地址。
< pluginGroups>
< pluginGroup> org.sonarsource.scanner.maven</ pluginGroup>
</ pluginGroups>
< profiles>
< profile>
< id> sonar</ id>
< activation>
< activeByDefault> true</ activeByDefault>
</ activation>
< properties>
< sonar.host.url>
http://172.25.104.13:9000
</ sonar.host.url>
</ properties>
</ profile>
</ profiles>
2.idea下载SonarLint插件
3.项目集成sonar,jacoco插件依赖,在pom.xml添加以下内容
< properties>
< sonar.version> 3.6.0.1398</ sonar.version>
< jacoco.version> 0.8.4</ jacoco.version>
</ properties>
< build>
< finalName> ${project.artifactId}</ finalName>
< pluginManagement>
< plugins>
< plugin>
< groupId> org.jacoco</ groupId>
< artifactId> jacoco-maven-plugin</ artifactId>
< version> ${jacoco.version}</ version>
< configuration> </ configuration>
</ plugin>
</ plugins>
</ pluginManagement>
< plugins>
< plugin>
< groupId> org.jacoco</ groupId>
< artifactId> jacoco-maven-plugin</ artifactId>
< executions>
< execution>
< id> jacoco-ut</ id>
< goals>
< goal> prepare-agent</ goal>
</ goals>
</ execution>
< execution>
< id> jacoco-it</ id>
< goals>
< goal> prepare-agent-integration</ goal>
</ goals>
</ execution>
< execution>
< id> jacoco-site</ id>
< phase> verify</ phase>
< goals>
< goal> report</ goal>
</ goals>
</ execution>
</ executions>
</ plugin>
< plugin>
< groupId> org.sonarsource.scanner.maven</ groupId>
< artifactId> sonar-maven-plugin</ artifactId>
< version> ${sonar.version}</ version>
</ plugin>
</ plugins>
</ build>
4.如果需要去除sonar不检索文件,可以这样配置
< properties>
< sonar.exclusions> **/com/test/*,**/com/test1/*</ sonar.exclusions>
</ properties>
5.至此全部配置完,可以进行sonar本地检测试验了,按照以下步骤操作。
6.至此完成sonar本地检测,可以去sonar服务器查看代码检测结果和代码的覆盖率。