1) Download Sonar Qube Server 5.3 server –>  SonarQube 5.3

Note : Sonar Qube will work with JDK1.7

2)  Un-Zip and go to the path where it has been installed ( Based on your System Type i.e 32 bit or 64 bit).

For example–>   I:\Sonar_Qube\sonarqube-5.3\sonarqube-5.3\bin\windows-x86-32 

SonarQube

3)  Start –> Sonar.bat

SonarQube_Console

4) Hit   http://localhost:9000  on any browser to see if the server is up

SonarQube_Site

5) Download SonarQube in Eclipse.

URL –>    sonar – http://downloads.sonarsource.com/eclipse/eclipse/

Paste the above url in Eclipse Market Place.Click on 1st Option and Finish Button. After installation it will ask for restart of Eclipse.

Eclipse_MarketPlace

Eclipse_MarketPlace_Installation

6) Go to Window–>Preferences–>SonarQube–>Servers.

Check if Server is properly configured.

Eclipse_Server_Check

7) In your Project Service/Java Folder, open pom.xml and make the below entries.

<properties>
<project.build.sourceEncoding> UTF-8 </project.build.sourceEncoding>
     <sonar.host.url>http://localhost:9000</sonar.host.url> 
</properties>

8)

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

<plugin>
                   <groupId>org.jacoco</groupId>
                   <artifactId>jacoco-maven-plugin</artifactId>
                   <version>0.7.0.201403182114</version>
                   <executions>
                         <execution>
                               <goals>
                                           <goal>prepare-agent</goal>
                              </goals>
                         </execution>
                    </executions>
                   <configuration>
                         <destFile>${sonar.jacoco.reportPath}</destFile>
                  </configuration>
       </plugin>
</plugins

9) Right Click on your Project –> Configure –> Associate with Sonar Qube

SonarQube_Associate

10)   Right Click on your Java Project pom.xml –> Run As –> Maven build

sonar_maven

11) Enter the below details and Click on Apply –>Run

clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dmaven.test.failure.ignore=true sonar:sonar

 

sonar_maven_command

Note: If the build fails for the first time, please re build again with the above command.

12)  In Eclipse Console, you will be able to see some logs regarding maven build and sonar analysis.

Sonar_Build

Sonar_Build_1

13) Once Build is successfully. Go to Sonar Localhost site .You will be able to see Java Project got included in SonarQube Analysis.

Sonar_Site

Sonar_Site_Quality_gate

Click on Issues Tab, you will be able to see all the Java related compliance issue.

Sonar_Site_Issue

14) You can also view the Unit Test Cases Coverage, under

 Measures–>Project name–>Coverage

Sonar_Site_coverage

 

15) You can define Rules

Sonar_Site_rules

 

 

 STEPS  TO  INLCUDE  SONAR  RULE  DUMP

=======================================

  1. Login as admin/admin

login

 

2. Click Quality Profile Menu

quality_profile

 

3) Click on Create –> Restore Profile

quality_profile

 

qualityprofile_create

Choose the Dump file

choose_file

 

4) Click on Restore

 

choose_dump

 

5) Once done, Set it as Default

set_default

 

set_default_1

 

6) Go to Home Page and click on Project

home_page_issues

 

 

Click on Issues

home_page_issue_1

You will see the new set of rules applied

dump_issues

 

dump_issues_1

 

 

 

 

 

Advertisements

One thought on “Sonar Qube Integration with Eclipse

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