comparison metrics.gradle @ 214:0ca4f3c952b7

DEP-11: add depency-lock plugin and a resolver to supply dynamic version based on branch. Cleanup metrics includes
author smith@nwoca.org
date Mon, 27 Jun 2016 19:50:00 +0100
parents 45d2396e9fc8
children 47535c8358ce
comparison
equal deleted inserted replaced
213:40316e0cdef2 214:0ca4f3c952b7
1 apply plugin: "sonar-runner" 1 apply plugin: "sonar-runner"
2 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties") 2 ant.property(file: System.getProperty('user.home') + "/.ssdt/sonar.properties")
3 3
4 if (!gradle.environment.containsKey('coverage')) {
5 gradle.environment.put('coverage', false)
6 } else {
7 gradle.environment.put('coverage', gradle.environment.coverage.toBoolean())
8 }
9
10 println "metrics: coverage enabled: ${gradle.environment.coverage}"
11 buildscript { 4 buildscript {
12 repositories { 5 repositories {
13 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' } 6 maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
14 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repo' } 7 maven { url 'http://repos.ssdt.nwoca.org/artifactory/repo' }
15 } 8 }
16 dependencies { 9 dependencies {
17 classpath 'me.davesmith:jaranalyzerplugin:0.2.0-SNAPSHOT' 10 classpath 'me.davesmith:jaranalyzerplugin:0.2.0-SNAPSHOT'
18 } 11 }
19 } 12 }
20 13
21
22 apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin 14 apply plugin: me.davesmith.gradle.plugins.jaranalyzer.JarAnalyzerPlugin
23 15
24 jaranalyzer { 16 jaranalyzer {
25 dot = true 17 dot = true
26 packageFilter += 'org.slf4j*' 18 packageFilter += 'org.slf4j*'
27 packageFilter += 'groovyx.*' 19 packageFilter += 'groovyx.*'
28 } 20 }
29
30 21
31 sonarRunner { 22 sonarRunner {
32 sonarProperties { 23 sonarProperties {
33 property "sonar.host.url", "http://sonar.ssdt-ohio.org/" 24 property "sonar.host.url", "http://sonar.ssdt-ohio.org/"
34 property "sonar.jdbc.url", ant.properties['sonar.jdbc.url'] 25 property "sonar.jdbc.url", ant.properties['sonar.jdbc.url']
38 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}" 29 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
39 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}" 30 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
40 } 31 }
41 } 32 }
42 33
43 if (gradle.environment.coverage) {
44
45 configurations {
46 jacocoAntRoot
47 }
48 dependencies {
49 jacocoAntRoot 'org.jacoco:org.jacoco.ant:0.6.2.201302030002'
50 }
51
52 task fullCoverageReport << {
53 ant {
54 taskdef(name: 'jacocoreport', classname: 'org.jacoco.ant.ReportTask', classpath: configurations.jacocoAntRoot.asPath)
55
56 mkdir dir: "${buildDir.path}/reports/coverage"
57
58 jacocoreport {
59 executiondata {
60 fileset(dir: "${buildDir.path}/coverage-results") {
61 include name: '*.jacoco.exec'
62 }
63 }
64
65 structure(name: project.name) {
66
67 classfiles {
68 subprojects.each { project ->
69 fileset dir: project.sourceSets.main.output.classesDir
70 }
71 }
72 sourcefiles(encoding: 'CP1252') {
73 subprojects.each { project ->
74 project.sourceSets.main.allGroovy.srcDirs.findAll { file(it).exists() } each {
75 fileset dir: "$it"
76 }
77 }
78 }
79 }
80
81 xml destfile: "${buildDir.path}/reports/coverage/jacoco.xml"
82 html destdir: "${buildDir.path}/reports/coverage"
83 }
84 }
85 }
86
87 fullCoverageReport.dependsOn {
88 subprojects.collect { project ->
89 project.copyCoverageData.path
90 }
91 }
92
93 }
94
95 subprojects { 34 subprojects {
96 afterEvaluate { project -> 35 afterEvaluate { project ->
97 36
98 def groovyProject = project.plugins.hasPlugin('groovy') 37 def groovyProject = project.plugins.hasPlugin('groovy')
99 def javaProject = project.plugins.hasPlugin('java')
100
101 if (gradle.environment.coverage && groovyProject) {
102 logger.info "coverage analysis enabled"
103 project.apply plugin: 'jacoco'
104
105 project.jacoco {
106 toolVersion = "0.6.3.201306030806"
107 }
108
109 project.test {
110 jacoco {
111 enabled = true
112 }
113 }
114 project.jacocoTestReport {
115 if (groovyProject) {
116 sourceDirectories = files(sourceSets.main.allGroovy.srcDirs)
117 classDirectories = files(project.sourceSets.main.output.classesDir)
118 }
119 reports {
120 xml.enabled true
121 csv.enabled false
122 html.enabled true
123 }
124 }
125
126 task coverageReport {
127 dependsOn jacocoTestReport
128 }
129
130 task copyCoverageData(dependsOn: test, type: Copy) {
131 from project.test.jacoco.destPath
132 into "${rootProject.buildDir.path}/coverage-results"
133 include 'test.exec'
134 rename 'test.exec', "${project.name}.jacoco.exec"
135 }
136
137 }
138
139 sonarRunner { 38 sonarRunner {
140 sonarProperties { 39 sonarProperties {
141 property "sonar.language", groovyProject ? 'grvy' : 'java' 40 property "sonar.language", groovyProject ? 'grvy' : 'java'
142 if (gradle.environment.coverage) {
143 property "sonar.java.coveragePlugin", "jacoco"
144 property "sonar.jacoco.reportPath", project.test.jacoco.destPath
145 }
146 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}" 41 property "sonar.build-stability.url", "http://bamboo.ssdt-ohio.org/browse/${gradle.bambooPlan}"
147 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}" 42 property "sonar.scm.url", "scm:hg:${gradle.hgRepositoryUrl}"
148 } 43 }
149 } 44 }
150
151 } 45 }
152 } 46 }
153
154
155 47
156 allprojects { 48 allprojects {
157 afterEvaluate { project -> 49 afterEvaluate { project ->
158 project.getTasksByName('sonarRunner',false).each { it.enabled = gradle.branchStream == 'develop' } 50 project.getTasksByName('sonarRunner',false).each { it.enabled = gradle.branchStream == 'develop' }
159 } 51 }
160 } 52 }