I am a little late in writing this series of articles on installing and using Sonar: it was Semana Santa in Spain, a week of holidays and so I wanted to enjoy it for the first time this year. And as the next week has been short but intense, I could not catch up.
Fortunately, we’re done with long articles on Oracle, and as the installation of Sonar is not very complicated – if you take the time to carefully observe every step – I hope to write posts shorter but more frequent.
If you get directly to this page without having looked at the previous posts, I encourage you to read them. In our environment, we chose to install a JDK (Java 6), Tomcat 7 and a Oracle 11 database, There are a few other posts to run your Oracle but also create a user (schema) for Sonar.
If you want to perform an upgrade of a Sonar existing version, not a new installation, you will find some indications on this page.
Installing and configuring Sonar
The first step of this installation will be to download the latest version of Sonar from the download page http://www.sonarsource.org/downloads/.
In our case, it will be a version 3.5.1. Obviously, you can install any newer version you may find.
So for this new instalation, we will download the file ‘sonar-3.5.1.zip’ and unzip it into a ‘sonar-3.5.1’ directory. In my case, I installed all my software in a folder ‘C:\Soft’ with a subdirectory specific to each software. After unzipping the zip file, I now have a directory ‘C:\Soft\Sonar\sonar-3.5.1’.
In this folder, we look into the directory ‘..\conf’ for the file ‘sonar.properties’ in order to edit it.
In this file, a user ‘sonar¡ is already defined with its password:
This corresponds to the Oracle user that we did create in a previous post: Create an Oracle user.
We do not want to use the database supplied by default with Sonar, so we put the following lines in comments:
# Comment the following line to deactivate the default embedded database.
# sonar.jdbc.url: jdbc:h2:tcp://localhost:9092/sonar
And we search for the section to set our Oracle connection:
My Oracle database is called JPORA11 and is installed on port 1521 (default port for Oracle) on my own machine ‘localhost’. These are the only parameters to be specified according to your own environment.
And that’s it.
Well, we still have to find the Oracle JDBC driver (thin client) ‘ojdbc6.jar’ and copy it into the Sonar directory ‘\extensions\jdbc-driver\oracle’. You can find this file in the directory‘\jdbc\lib’ of your Oracle environment (C:\ORA11\11.2.0\dbhome_1\jdbc\lib in mine).
You can also go to the Sonar requirements page, in the ‘Supported Platforms’ section and locate the Oracle 11.2.x link. This takes you to the Oracle site from where you can download this driver. You will need to connect with your Oracle account.
Install the Sonar webap
Last step: generate the file ‘sonar.war’ that we will use to deploy Sonar under Tomcat. Everyone knows what is a .war file: a compressed file that will allow us to install the Sonar web application – the Sonar dashboard.
Previously, you may want to download (from the Plugin Library page) the Sonar plugins you want to use. Copy them into the Sonar directory ‘\extensions\plugins’. It is not absolutely necessary, you can do it later. I will begin to use Sonar without any of these plugins.
To build the file ‘sonar.war’, simply run the file ‘build-war.bat’ from the directory ‘\war’. The .war will be generated in the same directory.
We can now deploy it. I just copy it into the directory ‘C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps’, then start the Tomcat service in order to create a new folder – a new webapp – ‘\sonar’.
The first time you install Sonar, it will take a few minutes to create the database schema in the Oracle user previously defined. Give it some time to accomplish this task before starting the Sonar webapp.
It is now available from the URL corresponding to the directory of the Sonar webapp: ‘http://localhost:8888/sonar/’ in my environment.
Et voilà. Before detailing the Sonar interface, we’ll wait for a first analysis, so that we can view data in the dashboard.
And to do that, we will install the Sonar-Runner. In the – very – next post.