Mercurial > public > develkit
annotate metrics.gradle @ 118:f84f1d5465c1
update code coverage for sonar 3.3
author | smith@nwoca.org |
---|---|
date | Thu, 01 Nov 2012 21:18:20 +0100 |
parents | 5e06e0629f85 |
children | 740e905fce78 |
rev | line source |
---|---|
85 | 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' } | |
116 | 11 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repository' } |
12 maven { url 'http://repos.ssdt.nwoca.org/artifactory/libs-snapshots' } | |
13 } | |
85 | 14 dependencies { |
116 | 15 classpath "me.davesmith:gradle-cobertura-plugin:1.0.2.SNAPSHOT" |
16 classpath "net.sourceforge.cobertura:cobertura:1.9.4.1" | |
85 | 17 } |
18 } | |
19 | |
20 | |
21 sonar { | |
22 server { | |
23 url = "http://sonar.ssdt-ohio.org" | |
24 } | |
25 database { | |
26 url = ant.properties['sonar.jdbc.url'] | |
27 driverClassName = ant.properties['sonar.jdbc.driverClassName'] | |
28 username = ant.properties['sonar.jdbc.username'] | |
29 password = ant.properties['sonar.jdbc.password'] | |
30 } | |
31 project { | |
32 dynamicAnalysis = "reuseReports" | |
33 sourceEncoding = "UTF-8" | |
34 } | |
117
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
35 withGlobalProperties { props -> |
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
36 props["sonar.language"] = "grvy" |
118 | 37 props['sonar.core.codeCoveragePlugin'] = 'cobertura' |
117
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
38 } |
85 | 39 } |
40 | |
41 class SsdtSonarSettings extends BuildAdapter implements BuildListener { | |
42 | |
43 def void projectsEvaluated(Gradle gradle) { | |
44 Project root = gradle.getRootProject() | |
45 | |
46 def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } } | |
47 | |
116 | 48 root.configure(testableProjects) { p -> |
85 | 49 def usesGroovy = configurations.any { it.name == 'groovy' } |
116 | 50 apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin |
85 | 51 |
52 sonar { | |
53 project { | |
117
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
54 language = usesGroovy ? 'groovy' : 'java' |
85 | 55 dynamicAnalysis = "reuseReports" |
56 sourceEncoding = "UTF-8" | |
108
bb3fa722df51
USASR-819: Update metrics.gradle to use reporting.baseDir instead of deprecated reportsDir
springer@nwoca.org
parents:
85
diff
changeset
|
57 coberturaReportPath = file("${reporting.baseDir}/cobertura/coverage.xml") |
85 | 58 withProjectProperties { props -> |
117
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
59 if (usesGroovy) { |
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
60 println "setting groovy profile on $p" |
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
61 props['sonar.profile'] = 'SSDT Groovy Way' |
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
62 } |
118 | 63 props['sonar.core.codeCoveragePlugin'] = 'cobertura' |
108
bb3fa722df51
USASR-819: Update metrics.gradle to use reporting.baseDir instead of deprecated reportsDir
springer@nwoca.org
parents:
85
diff
changeset
|
64 props['sonar.cobertura.reportPath'] = "${reporting.baseDir}/cobertura/coverage.xml" |
85 | 65 props["sonar.cpd.skip"] = true |
116 | 66 props['sonar.language'] = usesGroovy ? 'grvy' : 'java' |
85 | 67 } |
68 } | |
116 | 69 |
85 | 70 } |
71 | |
116 | 72 cobertura { |
73 if (usesGroovy) { | |
74 coverageSourceDirs = sourceSets.main.groovy.srcDirs | |
75 } | |
76 if (gradle.bambooBuild) { | |
77 coverageFormat = 'xml' | |
78 } | |
79 } | |
80 | |
85 | 81 } |
82 | |
83 root.allprojects { | |
84 | |
85 def thisProject = delegate | |
86 def usesGroovy = thisProject.configurations.any { it.name == 'groovy' } | |
87 | |
88 sonar { | |
89 project { | |
117
5e06e0629f85
correct groovy language setting and force profile name
smith@nwoca.org
parents:
116
diff
changeset
|
90 language = usesGroovy ? 'groovy' : 'java' |
85 | 91 dynamicAnalysis = "reuseReports" |
92 sourceEncoding = "UTF-8" | |
116 | 93 withProjectProperties { props -> |
118 | 94 props['sonar.core.codeCoveragePlugin'] = 'cobertura' |
116 | 95 props['sonar.language'] = usesGroovy ? 'grvy' : 'java' |
96 } | |
85 | 97 } |
98 } | |
99 | |
100 } | |
101 } | |
102 } |