Skip to content

examples of sonarqube integration with maven projects

Notifications You must be signed in to change notification settings

mohsiqba/sonar-maven

Repository files navigation

sonar-maven basic project

examples of sonarqube integration with simple basic maven projects

Table of Contents

maven basic modules

maven + sonar-maven-plugin

maven + sonar-scanner

maven + sonar-scanner

unit test coverage data + report

integration test coverage data + report

unit test + integration test combined report

maven + sonar-scanner

unit test + integration test combined coverage ratio

maven multi-module project

maven + sonar-maven-plugin

maven + sonar-scanner

maven + sonar-scanner unit test + integration test coverage ratio per module

local setup

Prerequisite

  • local setup if not having enterprise setup

    • setup/get-started-2-minutes

    • [OR] sonarqube server installation if not having.

      • using docker
        docker pull sonarqube
        docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube
      • manual manual setup
  • setup sonar-scanner cli (when not using maven-sonar-plugin)

    brew install sonar-scanner

Usage

  • Build the project, execute all the tests and analyze the project with SonarQube Scanner for Maven(from root of the project):
    • if using maven-sonar-plugin

      > mvn clean verify sonar:sonar

      please note maven-sonar-plugin doesn't take sonar-project.properties and therefore all properties either needs to be defined in pom.xml or command line argument using -D option. like -Dsonar.host.url=https://localhost:9000

    • if using sonar-scanner cli command

      > mvn clean install
      > sonar-scanner -Dproject.settings=sonar-project.properties  

Documentation