安装指南:http://docs.codehaus.org/display/SONAR/Installation+guide
http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions 下载
http://sonar.codehaus.org/downloads/
sonar整合代码覆盖率/规则检查等数据WEB图形化展现。 预先条件
在window xp上环境变量PATH已经加入D:apache-maven-2.0.9in
D:apache-maven-2.0.9my-webapp>java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build1.5.0_14-b03)
Java HotSpot(TM) Client VM (build1.5.0_14-b03, mixed mode)
D:apache-maven-2.0.9my-webapp>mvn -v
Maven version:2.0.9
Java version:1.5.0_14
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
安装
安装在,D:sonar-1.4.3conf
InstallNTService.bat安装服务
StartNTService.bat启动服务
IE:http://127.0.0.1:9000/初步测试。
缺省用户名密码:admin/admin
在WEB页面上创建DB,创建后可以看到D:sonar-1.4.3confsonar.properties
sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
IE展现图如下:
配置与maven2的关联
在$MAVEN_HOME/conf(如D:apache-maven-2.0.9conf)或者~/.m2下的settings.xml文件加入下面内容
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:derby://localhost:1527/sonar
</sonar.jdbc.url>
<sonar.jdbc.driver>org.apache.derby.jdbc.ClientDriver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://127.0.0.1:9000/</sonar.host.url>
</properties>
</profile>
配置一个maven2工程pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-webapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
编译发布
D:apache-maven-2.0.9my-webapp>mvn org.codehaus.sonar:sonar-maven-plugin:1.4.3:sonar -Dsonar.skipInstall=true
重新刷新IE数据,漂亮的数据图表展现在面前。