This repository has been archived by the owner on Feb 2, 2019. It is now read-only.
/
emma.gradle
73 lines (64 loc) · 1.89 KB
/
emma.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
configurations{
emma
}
dependencies{
emma "emma:emma:2.0.5312"
emma "emma:emma_ant:2.0.5312"
}
def emmaConvention = new EmmaPluginConvention(project)
project.convention.plugins.emma = emmaConvention
class EmmaPluginConvention{
def verbosityLevel = "info"
def reportPath;
def coverageFileName;
def tmpDir;
def instrDir;
def metaDataFilePath;
def emma(Closure close){
close.delegate = this;
close.run()
}
EmmaPluginConvention(Project project){
reportPath = "${project.reportsDir.absolutePath}/emma"
coverageFileName = "coverage"
tmpDir = "${project.buildDir}/tmp/emma"
instrDir = "${tmpDir}/instr"
metaDataFilePath = "${tmpDir}/metadata.emma"
}
}
test{
//setup JVM Arguments for emma coverage
jvmArgs "-Demma.coverage.out.file=${emmaConvention.metaDataFilePath}", "-Demma.coverage.out.merge=true"
//add
doFirst{
ant.taskdef( resource:"emma_ant.properties", classpath: configurations.emma.asPath)
ant.path(id:"run.classpath"){
pathelement(location:sourceSets.main.classesDir.absolutePath )
}
ant.emma(verbosity:"${emmaConvention.verbosityLevel}"){
instr(merge:"true", destdir:"${emmaConvention.instrDir}", instrpathref:"run.classpath", metadatafile:"${emmaConvention.metaDataFilePath}"){
instrpath{
fileset(dir:sourceSets.main.classesDir.absolutePath, includes:"*.class")
}
}
}
setClasspath(files("${emmaConvention.instrDir}") + configurations.emma + getClasspath())
}
doLast{
ant.path(id:"src.path"){
sourceSets.main.java.srcDirs.each{
pathelement(location:it.absolutePath )
}
}
ant.emma(enabled:"true"){
report(sourcepathref:"src.path"){
fileset(dir:"${emmaConvention.tmpDir}"){
include(name:"*.emma")
}
txt(outfile:"${emmaConvention.reportPath}/coverage.txt")
html(outfile:"${emmaConvention.reportPath}/coverage.html")
xml(outfile:"${emmaConvention.reportPath}/coverage.xml")
}
}
}
}