Mercurial > public > develkit
annotate metrics.gradle @ 133:0d8681ff046b
CM-133: fix sonar runner when coverage disabled
author | smith@nwoca.org |
---|---|
date | Thu, 06 Jun 2013 20:42:46 +0100 |
parents | 8a7c3673dee9 |
children | afafe40ae5a9 |
rev | line source |
---|---|
126 | 1 apply plugin: "sonar-runner" |
85 | 2 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties") |
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 |
133
0d8681ff046b
CM-133: fix sonar runner when coverage disabled
smith@nwoca.org
parents:
132
diff
changeset
|
10 println "metrics: coverage enabled: ${gradle.environment.coverage}" |
85 | 11 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
|
12 repositories { |
85 | 13 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' } |
116 | 14 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repository' } |
15 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
|
16 } |
85 | 17 } |
18 | |
126 | 19 sonarRunner { |
20 sonarProperties { | |
21 property "sonar.host.url", "http://sonar.ssdt-ohio.org/" | |
22 property "sonar.jdbc.url", ant.properties['sonar.jdbc.url'] | |
23 property "sonar.jdbc.driverClassName", ant.properties['sonar.jdbc.driverClassName'] | |
24 property "sonar.jdbc.username", ant.properties['sonar.jdbc.username'] | |
25 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
|
26 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
|
27 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
|
28 } |
85 | 29 } |
126 | 30 |
132
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
31 if (gradle.environment.coverage) { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
32 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
33 configurations { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
34 jacocoAntRoot |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
35 } |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
36 dependencies { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
37 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
|
38 } |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
39 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
40 task fullCoverageReport << { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
41 ant { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
42 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
|
43 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
44 mkdir dir: "${buildDir.path}/reports/coverage" |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
45 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
46 jacocoreport { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
47 executiondata { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
48 fileset(dir: "${buildDir.path}/coverage-results") { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
49 include name: '*.jacoco.exec' |
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 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
53 structure(name: project.name) { |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
54 |
132
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
55 classfiles { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
56 subprojects.each { project -> |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
57 fileset dir: project.sourceSets.main.output.classesDir |
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 } |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
60 sourcefiles(encoding: 'CP1252') { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
61 subprojects.each { project -> |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
62 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
|
63 fileset dir: "$it" |
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 } |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
67 } |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
68 |
132
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
69 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
|
70 html destdir: "${buildDir.path}/reports/coverage" |
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 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
75 fullCoverageReport.dependsOn { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
76 subprojects.collect { project -> |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
77 project.copyCoverageData.path |
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 |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
81 } |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
82 |
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
|
83 subprojects { |
126 | 84 afterEvaluate { project -> |
85 | 85 |
126 | 86 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
|
87 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
|
88 |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
89 if (gradle.environment.coverage && groovyProject) { |
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
90 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
|
91 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
|
92 |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
93 project.jacoco { |
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
94 toolVersion = "0.6.3.201306030806" |
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
95 } |
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
96 |
130
253374129034
CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents:
128
diff
changeset
|
97 project.test { |
253374129034
CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents:
128
diff
changeset
|
98 jacoco { |
131
ca34c067b178
CM-133: make coverage analysis controllable by property
smith@nwoca.org
parents:
130
diff
changeset
|
99 enabled = true |
130
253374129034
CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents:
128
diff
changeset
|
100 } |
253374129034
CM-133: disable jacoco task. causing errors in some tests (java1.7?)
smith@nwoca.org
parents:
128
diff
changeset
|
101 } |
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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 } |
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 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
|
108 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
|
109 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
|
110 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
|
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 |
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 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
|
115 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
|
116 } |
c93df17513f1
CM-133: add jacoco for standard coverage reports. Add sonar properties for SCM and bamboo plan
smith@nwoca.org
parents:
126
diff
changeset
|
117 |
132
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
118 task copyCoverageData(dependsOn: test, type: Copy) { |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
119 from project.test.jacoco.destPath |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
120 into "${rootProject.buildDir.path}/coverage-results" |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
121 include 'test.exec' |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
122 rename 'test.exec', "${project.name}.jacoco.exec" |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
123 } |
8a7c3673dee9
CM-133: add fullCoverageReport task for consolidated coverage report
smith@nwoca.org
parents:
131
diff
changeset
|
124 |
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
|
125 } |
126 | 126 |
127 sonarRunner { | |
128 sonarProperties { | |
129 property "sonar.language", groovyProject ? 'grvy' : 'java' | |
133
0d8681ff046b
CM-133: fix sonar runner when coverage disabled
smith@nwoca.org
parents:
132
diff
changeset
|
130 if (gradle.environment.coverage) { |
0d8681ff046b
CM-133: fix sonar runner when coverage disabled
smith@nwoca.org
parents:
132
diff
changeset
|
131 property "sonar.java.coveragePlugin", "jacoco" |
0d8681ff046b
CM-133: fix sonar runner when coverage disabled
smith@nwoca.org
parents:
132
diff
changeset
|
132 property "sonar.jacoco.reportPath", project.test.jacoco.destPath |
0d8681ff046b
CM-133: fix sonar runner when coverage disabled
smith@nwoca.org
parents:
132
diff
changeset
|
133 } |
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
|
134 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
|
135 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}" |
85 | 136 } |
137 } | |
138 } | |
126 | 139 } |