changeset 126:b2532280341e

CM-133: switch to sonar-runner
author smith@nwoca.org
date Tue, 04 Jun 2013 16:50:46 +0100
parents 81a8ecfbc8fa
children 2a4ea22a6dd3
files .hgignore init.gradle metrics.gradle
diffstat 3 files changed, 44 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Feb 16 17:37:43 2013 +0000
+++ b/.hgignore	Tue Jun 04 16:50:46 2013 +0100
@@ -3,4 +3,20 @@
 \.chg\..*$
 \.rej$
 \.conflict\~$
-~$	
+.*~$
+glob:out/*
+glob:lib/*
+glob:build/*
+glob:dist/*
+glob:nbproject/*
+glob:.idea/workspace.*
+glob:*.log
+glob:.gradle/*
+glob:.idea/*
+glob:*.iml
+glob:*.iws
+glob:*.ipr
+glob:gradle-app.*
+glob:build.xml
+glob:private*.*
+glob:*.pdf
--- a/init.gradle	Sat Feb 16 17:37:43 2013 +0000
+++ b/init.gradle	Tue Jun 04 16:50:46 2013 +0100
@@ -49,6 +49,15 @@
    apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" 
 }
 
+
+buildscript {
+    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' }
+    }
+}
+
 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle"   
 
 task wrapper(type: Wrapper) {}
@@ -145,7 +154,7 @@
                     }
                 }
                 
-                thisProject.tasks.add("publishLocal") {
+                thisProject.tasks.create("publishLocal") {
                     description = "Publishes this projects artifacts to developer's local repository"
                     dependsOn = ["uploadArchives"]
                 }
--- 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
+}