Sunday, 18 November 2018

Sonar Local setuP


Sonar Setup for Local Run

Installing Sonar server

·       Download Sonar Qube zip.

·       Extract the zip file in your choosen location.
·       Start Sonar Qube in terminal using following command
./sonar.sh start
$ cd ~/Softwares/sonarqube-6.7.4/bin/macosx-universal-64/
$ ./sonar.sh start
Starting SonarQube...
Started SonarQube.
·       Now, you can browse your sonar installation at http://localhost:9000

Integrating with your maven project

Note: Following pom.xml changes are already done for CTB Service and OEM portal projects.

·       Edit pom.xml
Modify your pom.xml to include following properties:
<properties>
                                                            <war.name>CTBOemService</war.name>
                                                            <local.jar.path>
                                                                                          /Users/10646250/Projects/July_Delivery/externalJars
                                                            </local.jar.path>
                                                            <output.dir>/Users/10646250/Projects/July_Delivery/wars</output.dir>
                                                            <!-- API versions -->
                                                            <spring-framework.version>5.0.3.RELEASE</spring-framework.version>
                                                            <hibernate.version>5.1.12.Final</hibernate.version>
                                                            <jacoco.plugin.version>0.8.1</jacoco.plugin.version>
                                                            <maven.test.skip>false</maven.test.skip>
                                                            <coverage.minimum>0%</coverage.minimum>
                                                            <sonar.host.url>http://localhost:9000</sonar.host.url>
                                                                                                    <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
                              </properties>


·       Ensure that JaCoCo includes configuration set
                                                  <configuration>
                            <destFile>${sonar.jacoco.reportPath}</destFile>
                            <append>true</append>
                    </configuration>



Integrating with Eclipse

·       Install SonarLint plugin using Eclipse marketplace


·       After installation, link your project with Sonar. Right click on the project and open Properties.





·       Select Bind this Eclipse project to a SonarQube project.
·       Select the project and select link above Connect to a SonarQube server.





Default username and password: admin/admin




Press on Finish button.
Note: If window doesn’t close, then close it by pressing on X on upper left corner of the window.

·       Run the maven build: mvn clean install
·       Run the sonar build: mvn sonar:sonar
·       Now, you can open the Sonar local portal (http://localhost:9000) to see your project code quality details.



That’s it.

No comments:

Post a Comment