annotate metrics.gradle @ 117:5e06e0629f85

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