Sonar是开源的代码质量管理平台,它把代码质量相关软件集成到一起统一管理,集成的软件如下:
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
CPD
Checkstyle
Clover
Cobertura
Findbugs
General
Google analytics
PMD
Squid
Surefire
我把安装过程记录下来.
1.环境准备如下
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
ubuntu8
.04
jdk1
.5
maven2
.2
(官方要求2
.0
.7以上)
mysql5
.0
2.下载Sonar,到http://sonar.codehaus.org/下载最新版本,目前是1.9.2,下载后解压即可
3.数据库配置
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
CREATE
DATABASE
sonar
CHARACTER
SET
utf8 COLLATE utf8_general_ci;
grant
all
on
sonar.
*
to
sonar@
'
%
'
identified
by
'
sonar
'
;
grant
all
on
sonar.
*
to
sonar
@localhost
identified
by
'
sonar
'
;
flush
privileges
;
官方没有
grant
all
on
sonar.
*
to
sonar@
'
%
'
identified
by
'
sonar
'
; 如果你想远程发布项目到sonar,那就需要加上这条
然后还要更改sonar的配置,在sonar的解压目录下打开conf/sonar.properties,注掉如下内容(如果你没有mysql就可以不改动这个文件,sonar默认使用内嵌数据库derby)
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
#sonar.jdbc.url: jdbc:derby://localhost:
1527
/sonar
;
create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(
1
)
去掉下面的注释
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
sonar.jdbc.url: jdbc:mysql://
192.168.1.151
:
3306
/sonar?useUnicode
=
true&characterEncoding
=
utf8
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select
1
Ok,配置已经完成你可以在bin目录项下进入相应平台的子目录,比如我的就是${sonar_home}bin/linux-x86-32,sonar是多平台的,你可以在bin目录下查找你对应的平台,然后执行
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> -->
${sonar_home}bin
/
linux
-
x86
-
32
/
sonar
.
sh start
启动后访问
http://localhost:9000就可以进入sonar了, 默认管理员用户和密码是admin/admin
大功告成!
今天先写到这,后面我会加上如何用maven发布一个项目到sonar上!
秀几张图来看看