Created
June 13, 2013 09:10
-
-
Save melix/5772326 to your computer and use it in GitHub Desktop.
Workaround for Sonar working only with leaf projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: "sonar-runner" | |
sonarRunner { | |
sonarProperties { | |
property "sonar.sourceEncoding", "UTF-8" | |
// must choose one and only one language, Sonar doesn't know about polyglot projects! | |
property "sonar.language", "java" | |
} | |
} | |
gradle.taskGraph.beforeTask { Task task -> | |
if (task instanceof org.gradle.api.sonar.runner.SonarRunner) { | |
configure(task) { | |
Properties props = new Properties() | |
def sp = sonarProperties | |
sp.sort().each { key, value -> | |
if (key in ['sonar.projectBaseDir', 'sonar.projectKey', 'sonar.projectVersion', 'sonar.sourceEncoding', 'sonar.sources', 'sonar.surefire.reportsPath', 'sonar.tests']) { | |
props["groovy-core.$key"] = value | |
} | |
} | |
props.each { key, value -> | |
sp[key] = value | |
} | |
sp['groovy-core.sonar.projectName'] = 'groovy-core' | |
sp['sonar.modules'] = "groovy-core,${sp['sonar.modules']}" | |
sonarProperties = sp | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment