INT-2393 Add Sonar Support (Gradle Plugin)

INT-2393 - Changes in Build.gradle based on Code Review
* Changed line to *jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.integration.*"*
* Added *props["sonar.jacoco.reportPath"] = "${buildDirName}/jacoco.exec" to make build work with default build directory*
* Therefore able to remove: *buildDir = "target"*
* Moved *sonar* block to bottom of build script
* Added comments around the **configurations** block
* Switched to use Gradle Properties instead of System Properties for Sonar parameters

INT-2393 - rootProject.hasProperty works
* More simplifications after finding out that **rootProject.hasProperty** works inside the Sonar closure

INT-2393 Based on code review: Fixed build.gradle
Based on Code Review, converted println statement to logger.info in build.gradle
This commit is contained in:
Gunnar Hillert
2012-01-11 14:52:59 -05:00
committed by Mark Fisher
parent c19191fe70
commit 92c974d443

View File

@@ -23,6 +23,7 @@ allprojects {
}
subprojects { subproject ->
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
@@ -60,6 +61,12 @@ subprojects { subproject ->
}
}
// See http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:configurations
// and http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html
configurations {
jacoco //Configuration Group used by Sonar to provide Code Coverage using JaCoCo
}
// dependencies that are common across all java projects
dependencies {
testCompile "cglib:cglib-nodep:$cglibVersion"
@@ -70,6 +77,7 @@ subprojects { subproject ->
testCompile "org.hamcrest:hamcrest-all:1.1"
testCompile "org.mockito:mockito-all:$mockitoVersion"
testCompile "org.springframework:spring-test:$springVersion"
jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.5.3.201107060350", classifier: "runtime"
}
// enable all compiler warnings; individual projects may customize further
@@ -79,6 +87,7 @@ subprojects { subproject ->
test {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)
jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.integration.*"
}
bundlor {
@@ -876,6 +885,41 @@ reference {
sourceDir = file('src/reference/docbook')
}
apply plugin: 'sonar'
sonar {
if (rootProject.hasProperty('sonarHostUrl')) {
server.url = rootProject.sonarHostUrl
}
database {
if (rootProject.hasProperty('sonarJdbcUrl')) {
url = rootProject.sonarJdbcUrl
}
if (rootProject.hasProperty('sonarJdbcDriver')) {
driverClassName = rootProject.sonarJdbcDriver
}
if (rootProject.hasProperty('sonarJdbcUsername')) {
username = rootProject.sonarJdbcUsername
}
if (rootProject.hasProperty('sonarJdbcPassword')) {
password = rootProject.sonarJdbcPassword
}
}
project {
dynamicAnalysis = "reuseReports"
withProjectProperties { props ->
props["sonar.core.codeCoveragePlugin"] = "jacoco"
props["sonar.jacoco.reportPath"] = "${buildDirName}/jacoco.exec"
}
}
logger.info("Sonar parameters used: server.url='${server.url}'; database.url='${database.url}'; database.driverClassName='${database.driverClassName}'; database.username='${database.username}'")
}
task api(type: Javadoc) {
group = 'Documentation'
description = 'Generates aggregated Javadoc API documentation.'