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.
Sonar 2.12 Installation
We download the sonar-2.12.zip (from this page) and unzip it. This creates a sonar-2.12 directory.
In this directory, go to the \conf sub-directory and edit the sonar.properties file. Here, the credentials for a sonar user are already defined:
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
We don’t want to use the default Derby database so, as indicated, we comment the following lines:
# Comment the following lines to deactivate the default embedded database.
sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
And we look to the section dedicated to Oracle to define the access to our Oracle database:
sonar.jdbc.url: jdbc:oracle:thin:@localhost:1521/JPORA11
sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver
And that’s all for the Sonar configuration.
Now, we need to find the Oracle JDBC driver (thin client) ‘ojdbc6.jar’ (look into \jdbc\lib into your Oracle installation) and copy it to the directory \extensions\jdbc-driver\oracle.
Last step: build the sonar.war file that we will use to deploy Sonar in Tomcat. But first, I recommand you to download (from this page) all the Sonar plugins that you want to install. Just put them into the Sonar directory \extensions\plugins. 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.
Just run the build-war.bat file from the \war directory and soon you will have the sonar.war file created.
We can now deploy it under Tomcat. I just copy it under C:\Program Files (x86)\Apache Software Foundation\Tomcat 7.0\webapps. Start Tomcat, and it will create a new \sonar directory with all the contents of the .war file.
Now, from my browser, I can access Sonar at the url corresponding to this web application under Tomcat.
Ah, don’t forget to configure the Tomcat Java pool to 512 Mb, as seen in the Sonar – Our environment page.
Java Runner Installation
We download the sonar-runner-1.1.zip directly from the Java Runner documentation page on Sonar site and unzip it. We now have a sonar-runner-1.1 directory.
In this directory, we go to the \conf directory and edit the sonar-runner.properties file.
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:
#—– Default directory layout
#sources=src/main/java
#tests=src/test/java
#binaries=target/classes
We want to dedicate this file only to the connection with the Sonar ‘server’ which is in fact our Sonar webapp under Tomcat. So, we just indicate its url:
#—– Default Sonar server
sonar.host.url=http://localhost:8888/sonar/
And the informations to connect to our Oracle database, as previously indicated during the Sonar installation.
#—– Oracle
sonar.jdbc.url: jdbc:oracle:thin:@localhost:1521/JPORA11
sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver
#—– Global database settings
sonar.jdbc.username: sonar
sonar.jdbc.password: sonar
And that’s it. To launch the Java Runner, we just have to run the sonar-runner.bat which is located into the \sonar-runner-1.1\bin directory. But this will the subject of our next post about our 1st analysis with Sonar.
This post is also available in Leer este articulo en castellano and Lire cet article en français.
Pingback: Sonar – Our environment | Qualilogy