changeset 85:f36eeb411845

add sonar publishing
author smith@nwoca.org
date Tue, 14 Feb 2012 15:18:45 -0500
parents fa7b349201eb
children da29f9bde0da
files init.gradle metrics.gradle
diffstat 2 files changed, 101 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/init.gradle	Fri Feb 10 13:22:29 2012 -0500
+++ b/init.gradle	Tue Feb 14 15:18:45 2012 -0500
@@ -1,13 +1,18 @@
 
 gradle.addListener(new ArtifactoryGradleSettings())
 
+
 gradle.bambooBuild = System.getenv().any { it.key.startsWith('BAMBOO')}
 logger.info "applying SSDT artifactory Gradle Settings (bamboo: $gradle.bambooBuild)"
 
 if (gradle.bambooBuild) {
-   apply from: "${gradle.hasProperty('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation :'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip'}/artifactory.gradle"
+   gradle.ssdtGradlekitLocation = gradle.hasProperty('ssdtGradlekitLocation') ? gradle.ssdtGradlekitLocation : 'http://hg.ssdt-ohio.org/ssdt/gradlekit/raw-file/tip'
+   apply from: "${gradle.ssdtGradlekitLocation}/artifactory.gradle" 
 }
 
+
+apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle"   
+
 task wrapper(type: Wrapper) {
     gradleVersion = '1.0-milestone-7'
 }
@@ -18,6 +23,7 @@
 }
 
 allprojects {
+
     task cleanLocal(description: "removes all artifacts from developer's local repository") << {
 
         def local = project.repositories.find { it.name == 'local' } 
@@ -26,12 +32,10 @@
             new File(System.properties['user.home'] + "/.ssdt/local-repo").deleteDir() 
         }
     }    
+    
     cleanLocal.onlyIf { 
         project.repositories.any { it.name == 'local' }
     }    
-    task publishLocal(dependsOn: 'uploadArchives') {
-        description = "Publishes this projects artifacts to developer's local repository"
-    }
     
 }
 
@@ -78,11 +82,16 @@
             }           
             
             if ( thisProject.repositories.find { it.name == 'local' } ) {
-                uploadArchives {
-                    repositories {                     
-                         add thisProject.repositories.local
-                    }
-                }
+ //               uploadArchives {
+ //                  repositories {                     
+ //                        add thisProject.repositories.local
+ //                   }
+ //               }
+                
+//                task publishLocal(dependsOn: 'uploadArchives') {
+//                   description = "Publishes this projects artifacts to developer's local repository"
+//                }
+
             }          
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/metrics.gradle	Tue Feb 14 15:18:45 2012 -0500
@@ -0,0 +1,83 @@
+
+apply plugin: "sonar"
+
+gradle.addListener(new SsdtSonarSettings())
+
+ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
+
+buildscript {
+  repositories {
+        maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
+    }
+    dependencies {
+        classpath "gradle_cobertura:gradle_cobertura:1.0"
+    }
+}
+
+
+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"                    
+    }  
+}
+    
+class SsdtSonarSettings extends BuildAdapter implements BuildListener {
+    
+    def void projectsEvaluated(Gradle gradle) {    
+        Project root = gradle.getRootProject()  
+
+        def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } }
+        
+        root.configure(testableProjects) {  ->
+            def usesGroovy = configurations.any { it.name == 'groovy' } 
+            apply {
+//                plugin com.orbitz.gradle.cobertura.CoberturaPlugin
+            }
+                        
+            sonar {
+                project {
+                    language = usesGroovy ? 'grvy' : 'java'
+                    dynamicAnalysis = "reuseReports"     
+                    sourceEncoding = "UTF-8"                    
+                    coberturaReportPath = file("$reportsDir/cobertura/coverage.xml")                   
+                    withProjectProperties { props ->
+                        props['sonar.cobertura.reportPath'] = "$reportsDir/cobertura/coverage.xml"
+                        props["sonar.cpd.skip"] = true
+                    }                    
+                }
+            }
+              
+//            cobertura {
+//                if (usesGroovy) {
+//                    coverageSourceDirs = sourceSets.main.groovy.srcDirs
+//                }            
+//            }
+            
+        }
+        
+        root.allprojects {
+ 
+            def thisProject = delegate     
+            def usesGroovy = thisProject.configurations.any { it.name == 'groovy' } 
+             
+            sonar {
+                project {                            
+                    language = usesGroovy ? 'grvy' : 'java'
+                    dynamicAnalysis = "reuseReports"     
+                    sourceEncoding = "UTF-8"
+                }
+            }
+          
+        }
+    }
+}
\ No newline at end of file