diff metrics.gradle @ 126:b2532280341e

CM-133: switch to sonar-runner
author smith@nwoca.org
date Tue, 04 Jun 2013 16:50:46 +0100
parents 740e905fce78
children c93df17513f1
line wrap: on
line diff
--- a/metrics.gradle	Sat Feb 16 17:37:43 2013 +0000
+++ b/metrics.gradle	Tue Jun 04 16:50:46 2013 +0100
@@ -1,7 +1,5 @@
 
-apply plugin: "sonar"
-
-gradle.addListener(new SsdtSonarSettings())
+apply plugin: "sonar-runner"
 
 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
 
@@ -17,90 +15,25 @@
     }
 }
 
-
-sonar {
-    server {
-        url = "http://sonar.ssdt-ohio.org"
-    }
-    database {
-        url = ant.properties['sonar.jdbc.url']
-        driverClassName = ant.properties['sonar.jdbc.driverClassName']
-        username = ant.properties['sonar.jdbc.username']
-        password = ant.properties['sonar.jdbc.password']
-    }
-    project {
-        dynamicAnalysis = "reuseReports"     
-        sourceEncoding = "UTF-8"                    
-    }  
-    withGlobalProperties { props ->
-        props["sonar.language"] = "grvy"
-        props['sonar.core.codeCoveragePlugin'] = 'cobertura'
+sonarRunner {
+    sonarProperties {
+        property "sonar.host.url", "http://sonar.ssdt-ohio.org/"
+        property "sonar.jdbc.url", ant.properties['sonar.jdbc.url']
+        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']
     }
 }
-    
-class SsdtSonarSettings extends BuildAdapter implements BuildListener {
-    
-    def void projectsEvaluated(Gradle gradle) {    
-        Project root = gradle.getRootProject()  
+
+allprojects {
+    afterEvaluate { project ->
 
-        def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } }
-        
-        root.configure(testableProjects) { p ->
-            def usesGroovy = configurations.any { it.name == 'groovy' } 
-            apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin
-                        
-            sonar {
-                project {
-                    language = usesGroovy ? 'groovy' : 'java'
-                    dynamicAnalysis = "reuseReports"     
-                    sourceEncoding = "UTF-8"                    
-                    coberturaReportPath = file("${reporting.baseDir}/cobertura/coverage.xml")                   
-                    withProjectProperties { props ->
-                        if (usesGroovy) {
-                            println "setting groovy profile on $p"
-                            props['sonar.profile'] = 'SSDT Groovy Way'
-                        }
-                        props['sonar.core.codeCoveragePlugin'] = 'cobertura'
-                        props['sonar.cobertura.reportPath'] = "${reporting.baseDir}/cobertura/coverage.xml"
-                        props["sonar.cpd.skip"] = true
-                        props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
-                    }                    
-                }
-                
+        def groovyProject = project.plugins.hasPlugin('groovy')
+
+        sonarRunner {
+            sonarProperties {
+                property "sonar.language", groovyProject ? 'grvy' : 'java'
             }
-              
-            cobertura {
-                if (usesGroovy) {
-                    coverageSourceDirs = sourceSets.main.groovy.srcDirs
-                }            
-                if (gradle.bambooBuild) {
-                    coverageFormat = 'xml'
-                }
-            }
-
-            if (gradle.bambooBuild) {
-                build.dependsOn 'cobertura'
-            }
-
-        }
-        
-        root.allprojects { 
- 
-            def thisProject = delegate     
-            def usesGroovy = thisProject.configurations.any { it.name == 'groovy' } 
-             
-            sonar {
-                project {                            
-                    language = usesGroovy ? 'groovy' : 'java'
-                    dynamicAnalysis = "reuseReports"     
-                    sourceEncoding = "UTF-8"
-                    withProjectProperties { props ->
-                        props['sonar.core.codeCoveragePlugin'] = 'cobertura'
-                        props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
-                    }                    
-                }
-            }
-         
         }
     }
-}
\ No newline at end of file
+}