安裝指南:http://docs.codehaus.org/display/SONAR/Installation+guide
http://docs.codehaus.org/display/SONAR/Frequently+Asked+Questions
下載
http://sonar.codehaus.org/downloads/
sonar整合代碼覆蓋率/規(guī)則檢查等數(shù)據(jù)WEB圖形化展現(xiàn)。
預(yù)先條件
在window xp上環(huán)境變量PATH已經(jīng)加入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安裝服務(wù)
StartNTService.bat啟動(dòng)服務(wù)
IE:http://127.0.0.1:9000/初步測(cè)試。
缺省用戶名密碼:admin/admin
在WEB頁(yè)面上創(chuàng)建DB,創(chuàng)建后可以看到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展現(xiàn)圖如下:
配置與maven2的關(guān)聯(lián)
在$MAVEN_HOME/conf(如D:apache-maven-2.0.9conf)或者~/.m2下的settings.xml文件加入下面內(nèi)容
<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>
配置一個(gè)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>
編譯發(fā)布
D:apache-maven-2.0.9my-webapp>mvn org.codehaus.sonar:sonar-maven-plugin:1.4.3:sonar -Dsonar.skipInstall=true
重新刷新IE數(shù)據(jù),漂亮的數(shù)據(jù)圖表展現(xiàn)在面前。