-
Notifications
You must be signed in to change notification settings - Fork 84
/
cobertura.gradle
51 lines (42 loc) · 1.44 KB
/
cobertura.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
logger.info "Configuring Cobertura Plugin"
configurations{
coberturaRuntime {extendsFrom testRuntime}
}
dependencies {
coberturaRuntime 'net.sourceforge.cobertura:cobertura:1.9.4'
}
def serFile="${project.buildDir}/cobertura.ser"
def classes="${project.buildDir}/classes/main"
def classesCopy="${classes}-copy"
task cobertura(type: Test){
dependencies {
testRuntime 'net.sourceforge.cobertura:cobertura:1.9.4'
}
systemProperty "net.sourceforge.cobertura.datafile", serFile
}
cobertura.doFirst {
logger.quiet "Instrumenting classes for Cobertura"
ant {
delete(file:serFile, failonerror:false)
delete(dir: classesCopy, failonerror:false)
copy(todir: classesCopy) { fileset(dir: classes) }
taskdef(resource:'tasks.properties', classpath: configurations.coberturaRuntime.asPath)
'cobertura-instrument'(datafile: serFile) {
fileset(dir: classes,
includes:"**/*.class",
excludes:"**/*Test.class")
}
}
}
cobertura.doLast{
if (new File(classesCopy).exists()) {
//create html cobertura report
ant.'cobertura-report'(destdir:"${project.reportsDir}/cobertura",
format:'html', srcdir:"src/main/java", datafile: serFile)
//create xml cobertura report
ant.'cobertura-report'(destdir:"${project.reportsDir}/cobertura",
format:'xml', srcdir:"src/main/java", datafile: serFile)
ant.delete(file: classes)
ant.move(file: classesCopy, tofile: classes)
}
}