sonar的安装和使用
安装
配置maven
settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Example for MySQL-->
<sonar.__my_company_1__bc.url>
__my_company_1__bc:h2:tcp://localhost:9092/sonar
</sonar.__my_company_1__bc.url>
<sonar.__my_company_1__bc.username>sonar</sonar.__my_company_1__bc.username>
<sonar.__my_company_1__bc.password>sonar</sonar.__my_company_1__bc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://localhost:9000
</sonar.host.url>
</properties>
<configuration>
<argLine>-Xmx1024m</argLine>
</configuration>
</profile>
</profiles>
</settings>
执行 sonar
- 启动sonar server
- 在项目目录中执行mvn命令:mvn sonar:sonar
start sonar-3.6.2\bin\windows-x86-32\StartSonar.bat set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m mvn sonar:sonar
执行完毕,访问下面的页面查看结果 http://localhost:9000 用户名/密码:admin/admin
Fedora 20
pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
mvn org.codehaus.sonar:sonar-maven3-plugin:3.7:sonar