comparison metrics.gradle @ 85:f36eeb411845

add sonar publishing
author smith@nwoca.org
date Tue, 14 Feb 2012 15:18:45 -0500
parents
children bb3fa722df51
comparison
equal deleted inserted replaced
84:fa7b349201eb 85:f36eeb411845
1
2 apply plugin: "sonar"
3
4 gradle.addListener(new SsdtSonarSettings())
5
6 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
7
8 buildscript {
9 repositories {
10 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
11 }
12 dependencies {
13 classpath "gradle_cobertura:gradle_cobertura:1.0"
14 }
15 }
16
17
18 sonar {
19 server {
20 url = "http://sonar.ssdt-ohio.org"
21 }
22 database {
23 url = ant.properties['sonar.jdbc.url']
24 driverClassName = ant.properties['sonar.jdbc.driverClassName']
25 username = ant.properties['sonar.jdbc.username']
26 password = ant.properties['sonar.jdbc.password']
27 }
28 project {
29 dynamicAnalysis = "reuseReports"
30 sourceEncoding = "UTF-8"
31 }
32 }
33
34 class SsdtSonarSettings extends BuildAdapter implements BuildListener {
35
36 def void projectsEvaluated(Gradle gradle) {
37 Project root = gradle.getRootProject()
38
39 def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } }
40
41 root.configure(testableProjects) { ->
42 def usesGroovy = configurations.any { it.name == 'groovy' }
43 apply {
44 // plugin com.orbitz.gradle.cobertura.CoberturaPlugin
45 }
46
47 sonar {
48 project {
49 language = usesGroovy ? 'grvy' : 'java'
50 dynamicAnalysis = "reuseReports"
51 sourceEncoding = "UTF-8"
52 coberturaReportPath = file("$reportsDir/cobertura/coverage.xml")
53 withProjectProperties { props ->
54 props['sonar.cobertura.reportPath'] = "$reportsDir/cobertura/coverage.xml"
55 props["sonar.cpd.skip"] = true
56 }
57 }
58 }
59
60 // cobertura {
61 // if (usesGroovy) {
62 // coverageSourceDirs = sourceSets.main.groovy.srcDirs
63 // }
64 // }
65
66 }
67
68 root.allprojects {
69
70 def thisProject = delegate
71 def usesGroovy = thisProject.configurations.any { it.name == 'groovy' }
72
73 sonar {
74 project {
75 language = usesGroovy ? 'grvy' : 'java'
76 dynamicAnalysis = "reuseReports"
77 sourceEncoding = "UTF-8"
78 }
79 }
80
81 }
82 }
83 }