annotate metrics.gradle @ 116:8f3ba3b811bf

update cobertura configuration
author smith@nwoca.org
date Thu, 01 Nov 2012 15:45:40 +0100
parents bb3fa722df51
children 5e06e0629f85
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 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
35 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
36
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
37 class SsdtSonarSettings extends BuildAdapter implements BuildListener {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
38
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
39 def void projectsEvaluated(Gradle gradle) {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
40 Project root = gradle.getRootProject()
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
41
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
42 def testableProjects = root.allprojects.findAll { it.configurations.any { it.name.contains('test') } }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
43
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
44 root.configure(testableProjects) { p ->
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
45 def usesGroovy = configurations.any { it.name == 'groovy' }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
46 apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
47
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
48 sonar {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
49 project {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
50 language = usesGroovy ? 'grvy' : 'java'
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
51 dynamicAnalysis = "reuseReports"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
52 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
53 coberturaReportPath = file("${reporting.baseDir}/cobertura/coverage.xml")
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
54 withProjectProperties { props ->
108
bb3fa722df51 USASR-819: Update metrics.gradle to use reporting.baseDir instead of deprecated reportsDir
springer@nwoca.org
parents: 85
diff changeset
55 props['sonar.cobertura.reportPath'] = "${reporting.baseDir}/cobertura/coverage.xml"
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
56 props["sonar.cpd.skip"] = true
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
57 props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
58 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
59 }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
60
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
61 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
62
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
63 cobertura {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
64 if (usesGroovy) {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
65 coverageSourceDirs = sourceSets.main.groovy.srcDirs
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
66 }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
67 if (gradle.bambooBuild) {
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
68 coverageFormat = 'xml'
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
69 }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
70 }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
71
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
72 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
73
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
74 root.allprojects {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
75
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
76 def thisProject = delegate
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
77 def usesGroovy = thisProject.configurations.any { it.name == 'groovy' }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
78
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
79 sonar {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
80 project {
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
81 language = usesGroovy ? 'grvy' : 'java'
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
82 dynamicAnalysis = "reuseReports"
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
83 sourceEncoding = "UTF-8"
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
84 withProjectProperties { props ->
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
85 props['sonar.language'] = usesGroovy ? 'grvy' : 'java'
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
86 }
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
87 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
88 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
89
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
90 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
91 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
92 }