annotate metrics.gradle @ 119:740e905fce78

execute cobertura for bamboo builds
author smith@nwoca.org
date Sat, 03 Nov 2012 16:21:25 +0100
parents f84f1d5465c1
children b2532280341e
rev   line source
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
1
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
2 apply plugin: "sonar"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
3
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
4 gradle.addListener(new SsdtSonarSettings())
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
5
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
6 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
7
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
8 buildscript {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
9 repositories {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
10 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
11 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repository' }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
12 maven { url 'http://repos.ssdt.nwoca.org/artifactory/libs-snapshots' }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
13 }
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
14 dependencies {
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
15 classpath "me.davesmith:gradle-cobertura-plugin:1.0.2.SNAPSHOT"
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
16 classpath "net.sourceforge.cobertura:cobertura:1.9.4.1"
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
17 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
18 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
19
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
20
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
21 sonar {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
22 server {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
23 url = "http://sonar.ssdt-ohio.org"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
24 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
25 database {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
26 url = ant.properties['sonar.jdbc.url']
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
27 driverClassName = ant.properties['sonar.jdbc.driverClassName']
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
28 username = ant.properties['sonar.jdbc.username']
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
29 password = ant.properties['sonar.jdbc.password']
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
30 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
31 project {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
32 dynamicAnalysis = "reuseReports"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
33 sourceEncoding = "UTF-8"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
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
f84f1d5465c1 update code coverage for sonar 3.3
smith@nwoca.org
parents: 117
diff changeset
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
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
39 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
40
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
41 class SsdtSonarSettings extends BuildAdapter implements BuildListener {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
42
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
43 def void projectsEvaluated(Gradle gradle) {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
44 Project root = gradle.getRootProject()
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
45
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
46 def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
47
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
48 root.configure(testableProjects) { p ->
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
49 def usesGroovy = configurations.any { it.name == 'groovy' }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
50 apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
51
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
52 sonar {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
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
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
55 dynamicAnalysis = "reuseReports"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
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
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
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
f84f1d5465c1 update code coverage for sonar 3.3
smith@nwoca.org
parents: 117
diff changeset
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
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
65 props["sonar.cpd.skip"] = true
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
66 props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
67 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
68 }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
69
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
70 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
71
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
72 cobertura {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
73 if (usesGroovy) {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
74 coverageSourceDirs = sourceSets.main.groovy.srcDirs
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
75 }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
76 if (gradle.bambooBuild) {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
77 coverageFormat = 'xml'
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
78 }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
79 }
119
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
80
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
81 if (gradle.bambooBuild) {
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
82 build.dependsOn 'cobertura'
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
83 }
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
84
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
85 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
86
119
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
87 root.allprojects {
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
88
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
89 def thisProject = delegate
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
90 def usesGroovy = thisProject.configurations.any { it.name == 'groovy' }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
91
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
92 sonar {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
93 project {
117
5e06e0629f85 correct groovy language setting and force profile name
smith@nwoca.org
parents: 116
diff changeset
94 language = usesGroovy ? 'groovy' : 'java'
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
95 dynamicAnalysis = "reuseReports"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
96 sourceEncoding = "UTF-8"
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
97 withProjectProperties { props ->
118
f84f1d5465c1 update code coverage for sonar 3.3
smith@nwoca.org
parents: 117
diff changeset
98 props['sonar.core.codeCoveragePlugin'] = 'cobertura'
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
99 props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
100 }
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
101 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
102 }
119
740e905fce78 execute cobertura for bamboo builds
smith@nwoca.org
parents: 118
diff changeset
103
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
104 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
105 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
106 }