Configuring Sonar In Your Window’s Desktop

1.  Install Sonar Server In Windows

In order to connect sonar maven plugin and/or sonar eclipse plugin to the local sonar server (for example in windows PC), you need to install the sonar server.

Here are the steps :

  • Download and unpack the sonar server zip file from here.
  • Start sonar server:

          bin\windows-x86-32\StartSonar.bat  (for 32 bit Windows)

  • Open Sonar admin page “http://localhost:9000“. Default credentials – admin/admin
  • Either create a new sonar profile by importing all rules files –                                                                                                               (a) Edit configuration given in top right web page: Configuration-> Create . Enter a profile name and select Checkstyle, Findbugs and PMD configuration files.

          (b) Click “Create” and set the new profile as default

  • Or restore the configuration from a backup – Configuration->System->Backup->Restore configuration.

2.  Install Sonar plugin in the Eclipse IDE

  • Help> Install New Software
  • Paste “http://dist.sonar-ide.codehaus.org/eclipse/ into the field named “Work with:” and press Enter.
  • Select: “Sonar Integration for Eclipse..
  • Click Next. Eclipse will then check to see if there are any issues which would prevent a successful installation.
  • Click Finish to begin the installation process. Eclipse will then download and install the necessary components.
  • Once the installation process is finished, Eclipse will ask you if you want to restart the IDE. It’s strongly recommended that you restart IDE.

3.  Eclipse Configuration After Sonar plugin installation

    (a) Server Configuration In Eclipse:-

  • Window > Preferences > Sonar
  • Add
  • Check if Sonar server lists shows a link like  http://localhost:9000. If it doesn’t then add the link as New Sonar Server Connection > Sonar Server URL.
  • Default credentials: admin/admin
  • Click Test Connection . (will get Successfully connected popup)
  • Ok …
  • Finish
  • Apply
  • Ok

   (b) Download “clover.licence” file from here. This is a FREE TRIAL VERSION and it is valid for only 30 days.

   (c) Edit the pom.xml of the maven project to include the below for which you need to run the sonar. Edit proper “licenceLocation” field.


<plugin>

<groupId>com.atlassian.maven.plugins</groupId>

<artifactId>maven-clover2-plugin</artifactId>

<version>2.6.3</version>

<configuration>

<licenseLocation>Give the absolute location of the “clover.license” file</licenseLocation>

</configuration>

<executions>

<execution>

<phase>verify</phase>

<goals>

<goal>instrument</goal>

<goal>check</goal>

</goals>

</execution>

</executions>

</plugin>

4.  Running the Maven project for analysing the code through Sonar.

     (a) Run Sonar on the maven project

          mvn clean install sonar:sonar

     (b) Once the build is succesfull, login to sonar admin page to see the violations. Below is a snippet for the same:

 

5. Configuring Sonar Eclipse

    (a) Link projects to Sonar Eclipse

          This linkage operation can be done by right-clicking on the the project into the “Package explorer”, and then by choosing “Configure ->   Associate with Sonar…”

     

You are now all done with configuration and can start using Sonar Eclipse. Change your eclipse perspective to “Sonar”.

Configuring JBoss server adapter for version > 5.0 in eclipse

Issue:

 

 

 

 

 

 

 

 

 

 

Resolution:

Download the JBoss AS Tool in eclipse using the below mentioned update site.

http://download.jboss.org/jbosstools/updates/development/indigo/ 

After succesful installation of the above tool, you can now configure all the versions of JBoss in your eclipse workbench.

How to resolve admin page opening issue after tomcat configuration in eclipse

Issue:

So often you would have noticed after tomcat configuration in eclipse, the admin start page never opens!

Reason:

Eclipse doesn’t copy the default application folders (e.g. ROOT) when it creates the tomcat specific folder inside the workspace.

Solution:

  1. Go to your “eclipse-workspace -> .metadata -> .plugins -> org.eclipse.wst.server.core -> tmp<number> -> wtpwebapps” directory
  2. Copy the ROOT folder from your “apache installation home -> webapps” directory to the directory mentioned in Step 1.  If prompted with overwrite dialog box, select yes and proceed.
  3. Reload http://localhost/ page. Admin start page should now open without any issues!