changeset 128:c93df17513f1

CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
author smith@nwoca.org
date Tue, 04 Jun 2013 23:13:59 +0100
parents 2a4ea22a6dd3
children bef2bfc61f6e
files init.gradle metrics.gradle
diffstat 2 files changed, 38 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/init.gradle	Tue Jun 04 16:51:29 2013 +0100
+++ b/init.gradle	Tue Jun 04 23:13:59 2013 +0100
@@ -14,6 +14,13 @@
 
 gradle.ext.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')} || hostname?.startsWith('ssdt-')
 
+gradle.ext.bambooPlan = System.getenv('BAMBOO_PLAN') ?: 'UNKNOWN'
+
+gradle.ext.hgRepositoryUrl = ""
+try {
+   gradle.ext.hgRepositoryUrl = "hg path".execute().text.split('=')[1].trim()
+} catch (e) {}
+
 rootProject.ext.indyCapable = {
     boolean capable = true
     try {
--- a/metrics.gradle	Tue Jun 04 16:51:29 2013 +0100
+++ b/metrics.gradle	Tue Jun 04 23:13:59 2013 +0100
@@ -1,14 +1,12 @@
-
 apply plugin: "sonar-runner"
-
 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
 
 buildscript {
-  repositories {
+    repositories {
         maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
         maven { url 'http://repos.ssdt.nwoca.org/artifactory/repository' }
         maven { url 'http://repos.ssdt.nwoca.org/artifactory/libs-snapshots' }
-   }
+    }
     dependencies {
         classpath "me.davesmith:gradle-cobertura-plugin:1.0.2.SNAPSHOT"
         classpath "net.sourceforge.cobertura:cobertura:1.9.4.1"
@@ -22,17 +20,45 @@
         property "sonar.jdbc.driverClassName", ant.properties['sonar.jdbc.driverClassName']
         property "sonar.jdbc.username", ant.properties['sonar.jdbc.username']
         property "sonar.jdbc.password", ant.properties['sonar.jdbc.password']
+        property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
+        property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
     }
 }
 
-allprojects {
+subprojects {
     afterEvaluate { project ->
 
         def groovyProject = project.plugins.hasPlugin('groovy')
+        def javaProject = project.plugins.hasPlugin('java')
+
+        if (groovyProject || javaProject) {
+            project.apply plugin: 'jacoco'
+
+            project.jacocoTestReport {
+                if (groovyProject) {
+                    sourceDirectories = files(sourceSets.main.allGroovy.srcDirs)
+                    classDirectories = files(project.sourceSets.main.output.classesDir)
+                }
+                reports {
+                    xml.enabled true
+                    csv.enabled false
+                    html.enabled true
+                }
+            }
+
+            task coverageReport {
+                dependsOn jacocoTestReport
+            }
+
+        }
 
         sonarRunner {
             sonarProperties {
                 property "sonar.language", groovyProject ? 'grvy' : 'java'
+                property "sonar.java.coveragePlugin", "jacoco"
+                property "sonar.jacoco.reportPath", project.test.jacoco.destPath
+                property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
+                property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
             }
         }
     }