RSS

Sonar setup

14 Mar

Hi folks,

Here is the elaborated post how to do the Sonar setup for your web application.

Just follow the below steps to setup Sonar code review tool for your application.

Step-1 :

1. In Eclipse, Go to Help -> Install New Software. This should display the “Install” dialog.
2. Paste the below URL into the field named “Work with:” and press Enter.
URL: http://dist.sonar-ide.codehaus.org/eclipse/

3. Choose the component listed under Sonar: “Sonar Integration for Eclipse (Required)”.
4. Click Next. Eclipse will then check to see if there are any issues which would prevent a successful installation.
5. Click Finish to begin the installation process. Eclipse will then downloads and install the necessary components.
6. Once the installation process is finished, Eclipse will ask you if you want to restart the IDE. It’s strongly recommended that you restart eclipse IDE.
7. In Eclipse , Go to Windows -> Preferences -> Sonar server
8. Remove http://nemo.sonarsource.org. and http://localhost:9000 as well.

Step-2:

1. Create a new folder (sonar setup) in your local machine, download the below 2 softwares from the google.
1. sonar 3.0
2. apache-maven-3.0.4-bin.zip

2 Modify the existing code in setting.xml file(location : apache-maven-3.0.4\conf\setting.xml) with your project information.
3. Create JAVA_HOME and MAVEN_HOME variable in users variable Section Under Environment Variables (User Variables and also in System variables)
4. Create pom.xml file and place in the below location : apache-maven-2.2.1\bin

sample pom.xml
<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”&gt;
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-check-api</artifactId>
<name>your project name</name>
<version>1.0</version>
<build>
<sourceDirectory>source code path (path for java classes directory)</sourceDirectory>
<outputDirectory>path for classes directory</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
</properties>
</project>

Note: In the above configuration, modify sourceDirectory and outputDirectory value path to your local machine path.

Step-3

1. Start Sonar Server by clicking on StartSonar.bat command (location:sonar-3.0\bin\windows-x86-32\StartSonar.bat)
2. Do the Clean build using the below maven commands:
In Command Prompt, go to the location: apache-maven-3.0.4\bin and start executing the below commands, make sure that below 2 commands will execute with out any errors.
1. mvn clean install sonar:sonar
2. mvn sonar:sonar
3. Use the below URL to see the dashboard of your application
Local URL: http://localhost:9000/

Reference URLs:

1. http://docs.codehaus.org/display/SONAR/Install+Sonar
2. http://sonarpvwin:9000/
3. http://docs.codehaus.org/display/SONAR/Configuring+Sonar+in+Eclipse
4. http://docs.codehaus.org/display/SONAR/Sonar+Plugin+Library/

Happy Learning!!.

Get glued to know more updates.

Have a nice day šŸ™‚

Advertisements
 
Leave a comment

Posted by on March 14, 2013 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: