Sonar is an open source platform for code quality management. It covers different aspects of code quality management like code duplication, complexity, coverage by unit tests, architecture & design, rule based defect identification etc. This post will help you to get started with Sonar in few minutes.
Tools and Technologies used in this article
1. Download and Install Sonar
Download Sonar 3.5.1 and extract the same in your local directory.
Note: Name of the folder / directory where you have unzipped Sonar should not start with digit.
2. Start Sonar Server
Open the terminal and execute the command '
static-108:~ abhimun$ /Users/srccodes/sonar-3.5.1/bin/macosx-universal-64/sonar.sh console Running sonar... wrapper | --> Wrapper Started as Console wrapper | Launching a JVM... jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. jvm 1 | jvm 1 | 2013-05-12 23:39:23.328:INFO::Logging to [email protected] via org.sonar.application.FilteredLogger jvm 1 | 2013-05-12 23:39:23.364:INFO::jetty-6.1.25 jvm 1 | 2013-05-12 23:39:23.501:INFO::NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet jvm 1 | JRuby limited openssl loaded. http://jruby.org/openssl jvm 1 | gem install jruby-openssl for full support. jvm 1 | 2013-05-12 23:39:44.160:INFO::Started [email protected]:9000
Sonar provides different scripts for different operating systems. Based on your OS execute the corresponding script available inside 'bin' folder. For example, if you have Windows-X86 32 bit machine, then execute '
Once started, Sonar application will be available on http://localhost:9000. Sonar by default runs on Jetty Webserver and uses embedded database H2.
# Listen host/port and context path (for example / or /sonar). Default values are 0.0.0.0:9000/. #sonar.web.host: 0.0.0.0 #sonar.web.port: 9000 #sonar.web.context: /
It is recommended to use other database like Oracle, MySQL, SQLServer etc for production environment. In this post, we have used default embedded database H2 for testing purpose only.
4. Browse Sonar Application
Browse to http://localhost:9000 for Sonar exploring administrative features. Use admin/admin as Login/Password to login to the application as administrator.