Soccertrash
Soccertrash

Reputation: 1901

Read SonarQube properties of gradle plugin

I'm using Gradle 2.14. I'd like to read the report-task.txt generated by the SonarQube Gradle plugin. For this purpose I need to get the location of this file which is stored in

sonarqube {
    properties {
        sonar.working.directory "..."
    }
}

I want to access this property from outside the sonarqube plugin, i.e. I'm writing a gradle task that runs after the sonar task. This tasks needs to process the report-task.txt located in sonar.working.directory.

Is is possible to access the properties of a gradle plugin?

Upvotes: 4

Views: 1750

Answers (1)

Crazyjavahacking
Crazyjavahacking

Reputation: 9687

The task sonarqube exposes all of the defined properties:

plugins {
    id "org.sonarqube" version "2.0.1"
}

sonarqube {
    properties {
        property "sonar.working.directory", "..."
    }
}

task printSonarqubeProperty {
    doLast {
        println "${project.tasks['sonarqube'].properties['sonar.working.directory']}"
    }
}

Upvotes: 6

Related Questions