Search code examples
androidsonarqubeandroid-gradle-pluginlintsonar-runner

How to update project using gradle automatically when executing sonar-runner?


I am using:

  • Android Studio 1.2
  • SonarQube 5.1

...and I want to force the project build of Android app before passing SonarQube, maybe modifying gradle configuration file.

I have added the next lines to build.gradle file:

apply plugin: "sonar-runner"

sonarRunner {
    sonarProperties {
        property "sonar.host.url", "http://localhost:9000"
        property "sonar.analysis.mode", "incremental"
        property 'sonar.sourceEncoding', 'UTF-8'
        property 'sonar.language', 'java'
        property "sonar.sources", "src/main"
        property 'sonar.profile', 'Android Lint'
        property 'sonar.import_unknown_files', 'true'
    }
}

subprojects {
    sonarRunner {
        sonarProperties {
            property "sonar.sources", "src/main"
        }
    }
}

What should I change in order to achieve the desired behaviour?


Solution

  • Simply add a new line to module build.gradle file, just after sonarRunner task declaration:

    sonarRunner {
        tasks.sonarRunner.dependsOn build  // <- This new line
        sonarProperties {