{"id":71,"date":"2011-12-21T15:51:44","date_gmt":"2011-12-21T14:51:44","guid":{"rendered":"http:\/\/dev.qualilogy.com\/en\/?p=71"},"modified":"2013-01-04T15:52:56","modified_gmt":"2013-01-04T14:52:56","slug":"sonar-installation","status":"publish","type":"post","link":"http:\/\/qualilogy.com\/en\/sonar-installation\/","title":{"rendered":"Sonar &#8211; Installation"},"content":{"rendered":"<p>The objectives of this post are to describe the installation of Sonar. We also want to install the Sonar Java Runner, to show that we can use Sonar without Maven or Ant. <!--more--><\/p>\n<h3><span style=\"text-decoration: underline;\">Sonar 2.12 Installation<\/span><\/h3>\n<p>We download the sonar-2.12.zip (<a title=\"Sonar 2.12\" href=\"http:\/\/www.sonarsource.org\/downloads\/\" target=\"_blank\">from this page<\/a>) and unzip it. This creates a <strong>sonar-2.12<\/strong> directory.<\/p>\n<p>In this directory, go to the <strong>\\conf<\/strong> sub-directory and edit the <strong>sonar.properties<\/strong> file. Here, the credentials for a <strong>sonar<\/strong> user are already defined:<\/p>\n<p style=\"padding-left: 30px;\"><strong>sonar.jdbc.username:                     sonar<\/strong><br \/>\n<strong> sonar.jdbc.password:                      sonar<\/strong><\/p>\n<p>We don&#8217;t want to use the default Derby database so, as indicated, we comment the following lines:<\/p>\n<p style=\"padding-left: 30px;\"># Comment the following lines to deactivate the default embedded database.<br \/>\n<strong>sonar.jdbc.url:                             jdbc:derby:\/\/localhost:1527\/sonar;create=true<\/strong><br \/>\n<strong>sonar.jdbc.driverClassName:  org.apache.derby.jdbc.ClientDriver<\/strong><\/p>\n<p>And we look to the section dedicated to Oracle to define the access to our Oracle database:<\/p>\n<p style=\"padding-left: 30px;\"><strong>sonar.jdbc.url:                           jdbc:oracle:thin:@localhost:1521\/JPORA11<\/strong><br \/>\n<strong>sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver<\/strong><\/p>\n<p>And that&#8217;s all for the Sonar configuration.<\/p>\n<p>Now, we need to find the Oracle JDBC driver (thin client) \u2018ojdbc6.jar\u2019 (look into \\jdbc\\lib into your Oracle installation) and copy it to the directory <strong>\\extensions\\jdbc-driver\\oracle<\/strong>.<\/p>\n<p>Last step: build the sonar.war file that we will use to deploy Sonar in Tomcat. But first, I recommand you to download (<a title=\"Sonar plugins\" href=\"http:\/\/docs.codehaus.org\/display\/SONAR\/Sonar+Plugin+Library\" target=\"_blank\">from this page<\/a>) all the Sonar plugins that you want to install. Just put them into the Sonar directory <strong>\\extensions\\plugins<\/strong>. It is not mandatory to do it now, you can wait. But if you do it later, you will have to start again Sonar in order to load the plugin, so better do it now.<\/p>\n<p>Just run the <strong>build-war.bat<\/strong> file from the <strong>\\war<\/strong> directory and soon you will have the sonar.war file created.<\/p>\n<p>We can now deploy it under Tomcat. I just copy it under <strong>C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 7.0\\webapps<\/strong>. Start Tomcat, and it will create a new <strong>\\sonar<\/strong> directory with all the contents of the .war file.<\/p>\n<p><a href=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/Sonar_url.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-437\" title=\"Sonar_url\" src=\"http:\/\/qualilogy.com\/wp-content\/uploads\/2011\/12\/Sonar_url.jpg\" alt=\"\" width=\"403\" height=\"135\" \/><\/a>Now, from my browser, I can access Sonar at the url corresponding to this web application under Tomcat.<\/p>\n<p>Ah, don&#8217;t forget to configure the Tomcat Java pool to 512 Mb, as seen in the <a title=\"Sonar - Our environment\" href=\"http:\/\/qualilogy.com\/code-analysis-tools\/sonar-environment\" target=\"_blank\">Sonar &#8211; Our environment<\/a> page.<\/p>\n<h3><span style=\"text-decoration: underline;\">Java Runner Installation<\/span><\/h3>\n<p>We download the sonar-runner-1.1.zip directly from the <a href=\"http:\/\/docs.codehaus.org\/display\/SONAR\/Analyse+with+a+simple+Java+Runner\" target=\"_blank\">Java Runner documentation page on Sonar site<\/a> and unzip it. We now have a <strong>sonar-runner-1.1<\/strong> directory.<\/p>\n<p>In this directory, we go to the <strong>\\conf<\/strong> directory and edit the <strong>sonar-runner.properties<\/strong> file.<\/p>\n<p>We do not want to use this file to define parameters specific to an analysis, as for example the source directory. So we comment the first lines:<\/p>\n<p style=\"padding-left: 30px;\"><strong>#&#8212;&#8211; Default directory layout<\/strong><br \/>\n<strong><strong>#<\/strong>sources=src\/main\/java<\/strong><br \/>\n<strong><strong>#<\/strong>tests=src\/test\/java<\/strong><br \/>\n<strong><strong>#<\/strong>binaries=target\/classes<\/strong><\/p>\n<p>We want to dedicate this file only to the connection with the Sonar &#8216;server&#8217; which is in fact our Sonar webapp under Tomcat. So, we just indicate its url:<\/p>\n<p style=\"padding-left: 30px;\"><strong>#&#8212;&#8211; Default Sonar server<\/strong><br \/>\n<strong>sonar.host.url=http:\/\/localhost:8888\/sonar\/<\/strong><\/p>\n<p>And the informations to connect to our Oracle database, as previously indicated during the Sonar installation.<\/p>\n<p style=\"padding-left: 30px;\">#&#8212;&#8211; Oracle<br \/>\n<strong>sonar.jdbc.url:                              jdbc:oracle:thin:@localhost:1521\/JPORA11<\/strong><br \/>\n<strong>sonar.jdbc.driverClassName:    oracle.jdbc.driver.OracleDriver<\/strong><\/p>\n<p style=\"padding-left: 30px;\">#&#8212;&#8211; Global database settings<br \/>\n<strong>sonar.jdbc.username:            sonar<\/strong><br \/>\n<strong>sonar.jdbc.password:            sonar<\/strong><\/p>\n<p>And that&#8217;s it. To launch the Java Runner, we just have to run the <strong>sonar-runner.bat<\/strong> which is located into the <strong>\\sonar-runner-1.1\\bin<\/strong> directory. But this will the subject of our next post about <a title=\"Sonar - 1st analysis\" href=\"http:\/\/qualilogy.com\/en\/sonar-first-analysis \">our 1st analysis with Sonar<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The objectives of this post are to describe the installation of Sonar. We also want to install the Sonar Java Runner, to show that we can use Sonar without Maven or Ant.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-sonar-installation"],"_links":{"self":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/71"}],"collection":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":2,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":73,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/posts\/71\/revisions\/73"}],"wp:attachment":[{"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qualilogy.com\/en\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}