view metrics.gradle @ 101:df191eeb14ac

USASR-800: upgrade for grale 1.0-ml9
author smith@nwoca.org
date Sat, 31 Mar 2012 18:28:13 +0100
parents f36eeb411845
children bb3fa722df51
line wrap: on
line source

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"
                }
            }
          
        }
    }
}