annotate metrics.gradle @ 132:8a7c3673dee9

CM-133: add fullCoverageReport task for consolidated coverage report
author smith@nwoca.org
date Thu, 06 Jun 2013 18:54:27 +0100
parents ca34c067b178
children 0d8681ff046b
rev   line source
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
1 apply plugin: "sonar-runner"
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
2 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
3
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
4 if (!gradle.environment.containsKey('coverage')) {
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
5 gradle.environment.put('coverage', false)
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
6 } else {
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
7 gradle.environment.put('coverage', gradle.environment.coverage.toBoolean())
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
8 }
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
9
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
10 buildscript {
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
11 repositories {
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
12 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
116
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
13 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repository' }
8f3ba3b811bf update cobertura configuration
smith@nwoca.org
parents: 108
diff changeset
14 maven { url 'http://repos.ssdt.nwoca.org/artifactory/libs-snapshots' }
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
15 }
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
16 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
17
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
18 sonarRunner {
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
19 sonarProperties {
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
20 property "sonar.host.url", "http://sonar.ssdt-ohio.org/"
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
21 property "sonar.jdbc.url", ant.properties['sonar.jdbc.url']
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
22 property "sonar.jdbc.driverClassName", ant.properties['sonar.jdbc.driverClassName']
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
23 property "sonar.jdbc.username", ant.properties['sonar.jdbc.username']
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
24 property "sonar.jdbc.password", ant.properties['sonar.jdbc.password']
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
25 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
26 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
117
5e06e0629f85 correct groovy language setting and force profile name
smith@nwoca.org
parents: 116
diff changeset
27 }
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
28 }
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
29
132
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
30 if (gradle.environment.coverage) {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
31
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
32 configurations {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
33 jacocoAntRoot
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
34 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
35 dependencies {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
36 jacocoAntRoot 'org.jacoco:org.jacoco.ant:0.6.2.201302030002'
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
37 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
38
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
39 task fullCoverageReport << {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
40 ant {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
41 taskdef(name:'jacocoreport', classname: 'org.jacoco.ant.ReportTask', classpath: configurations.jacocoAntRoot.asPath)
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
42
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
43 mkdir dir: "${buildDir.path}/reports/coverage"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
44
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
45 jacocoreport {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
46 executiondata {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
47 fileset(dir: "${buildDir.path}/coverage-results") {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
48 include name: '*.jacoco.exec'
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
49 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
50 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
51
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
52 structure(name: project.name) {
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
53
132
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
54 classfiles {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
55 subprojects.each { project ->
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
56 fileset dir: project.sourceSets.main.output.classesDir
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
57 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
58 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
59 sourcefiles(encoding: 'CP1252') {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
60 subprojects.each { project ->
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
61 project.sourceSets.main.allGroovy.srcDirs.findAll { file(it).exists() } each {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
62 fileset dir: "$it"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
63 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
64 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
65 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
66 }
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
67
132
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
68 xml destfile: "${buildDir.path}/reports/coverage/jacoco.xml"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
69 html destdir: "${buildDir.path}/reports/coverage"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
70 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
71 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
72 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
73
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
74 fullCoverageReport.dependsOn {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
75 subprojects.collect { project ->
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
76 project.copyCoverageData.path
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
77 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
78 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
79
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
80 }
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
81
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
82 subprojects {
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
83 afterEvaluate { project ->
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
84
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
85 def groovyProject = project.plugins.hasPlugin('groovy')
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
86 def javaProject = project.plugins.hasPlugin('java')
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
87
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
88 if (gradle.environment.coverage && groovyProject) {
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
89 logger.info "coverage analysis enabled"
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
90 project.apply plugin: 'jacoco'
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
91
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
92 project.jacoco {
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
93 toolVersion = "0.6.3.201306030806"
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
94 }
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
95
130
253374129034 CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents: 128
diff changeset
96 project.test {
253374129034 CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents: 128
diff changeset
97 jacoco {
131
ca34c067b178 CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents: 130
diff changeset
98 enabled = true
130
253374129034 CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents: 128
diff changeset
99 }
253374129034 CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents: 128
diff changeset
100 }
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
101 project.jacocoTestReport {
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
102 if (groovyProject) {
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
103 sourceDirectories = files(sourceSets.main.allGroovy.srcDirs)
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
104 classDirectories = files(project.sourceSets.main.output.classesDir)
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
105 }
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
106 reports {
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
107 xml.enabled true
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
108 csv.enabled false
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
109 html.enabled true
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
110 }
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
111 }
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
112
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
113 task coverageReport {
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
114 dependsOn jacocoTestReport
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
115 }
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
116
132
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
117 task copyCoverageData(dependsOn: test, type: Copy) {
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
118 from project.test.jacoco.destPath
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
119 into "${rootProject.buildDir.path}/coverage-results"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
120 include 'test.exec'
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
121 rename 'test.exec', "${project.name}.jacoco.exec"
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
122 }
8a7c3673dee9 CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents: 131
diff changeset
123
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
124 }
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
125
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
126 sonarRunner {
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
127 sonarProperties {
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
128 property "sonar.language", groovyProject ? 'grvy' : 'java'
128
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
129 property "sonar.java.coveragePlugin", "jacoco"
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
130 property "sonar.jacoco.reportPath", project.test.jacoco.destPath
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
131 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
c93df17513f1 CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents: 126
diff changeset
132 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
85
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
133 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
134 }
f36eeb411845 add sonar publishing
smith@nwoca.org
parents:
diff changeset
135 }
126
b2532280341e CM-133: switch to sonar-runner
smith@nwoca.org
parents: 119
diff changeset
136 }