What is Sonar?
Sonar is an Open Source
Software Quality platform. It uses various static code analysis tools such as Checkstyle,
PMD,
FindBugs to
extract software metrics, which then can be used to improve software quality.
It covers the
7 axes of code quality:
See List of Static
Code Analysis Tools:
How to install Sonar?
Step 1 – Install Sonar
Download the latest distribution from http://sonar.codehaus.org/downloads/
and extract the zip file in some folder (say D:\Sonar3).
Step 2 - Configure Database
If you do not use the default embedded Derby database, you need to edit D:\Sonar3\conf\sonar.properties file to configure the database access. Templates are available for every supported database. Just uncomment them and comment the first four lines dedicated to Derby database.- sonar.jdbc.url : the URL of the database
- sonar.jdbc.driver : the class of the driver
- sonar.jdbc.user : the username (default value is 'sonar')
- sonar.jdbc.password : the password (default value is 'sonar')
#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.defaultTransactionIsolation: 1
#sonar.jdbc.validationQuery: values(1)
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select 1
sonar.jdbc.user : root
sonar.jdbc.password: root
Step 3 - Create Database
Now, create a
database name sonardb, which we had configured in sonar.properties file. And grant all
privileges to user (root) created.
Step 4 - Start server
The default
listen port is 9000, the default
context path is / and Sonar listens
by default to all network interfaces: '0.0.0.0'. Once launched, the Sonar web
server is available on http://localhost:9000.
Parameters
can be changed into the file conf/sonar.properties.
Here is an example to listen to http://localhost:9091/sonar:
Uncomment and edit the
below lines as follows:
sonar.web.host
: 192.168.181.1
sonar.web.port: 9091
sonar.web.context: /sonar
Now, execute
the following script depending on your Operating System (32-bit / 64-bit) to
start the server:
D:\Sonar3\bin\windows-x86-32\StartSonar.bat
Wait for some
time (30-40 seconds) and check the log in console:
Hit on your
browser http://localhost:9000 or http://192.168.181.1:9091/sonar/ (if
you have modified the sonar.web.xxxx
parameters). You will see the following screen.
No comments:
Post a Comment