Book Image

Mastering Gradle

Book Image

Mastering Gradle

Overview of this book

Table of Contents (17 chapters)
Mastering Gradle
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Sonar Runner plugin


Sonar is one of the most popular quality management tools which gives complete analysis of a project in terms of lines of code, documentation, test coverage, issues and complexities. Gradle provides seamless integration with Sonar. The only prerequisite is that sonar server should be installed and running. Details on Sonar can be found at http://www.sonarqube.org/.

To run sonar runner plugin, we just need to apply plugin sonar-runner and configure it to connect to the sonar server.

Create build file build_sonar.gradle for your project with the following contents:

apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: "sonar-runner"

repositories {
  mavenCentral()
}

version = '1.0'

sonarRunner {

  sonarProperties {
    property "sonar.host.url", "http://<IP_ADDRESS>:9000"
    property "sonar.jdbc.url", "jdbc:h2:tcp://<IP_ADDRESS>:9092/sonar"
    property "sonar.jdbc.driverClassName", "org.h2.Driver"
    property "sonar.jdbc.username", "sonar"
  ...