Skip to content

Instantly share code, notes, and snippets.

@kyonmm

kyonmm/emma.gradle Secret

Created May 13, 2011
Embed
What would you like to do?
Emma for Gradle
apply plugin:'java'
configurations{
emma
}
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{
jvmArgs "-Demma.coverage.out.file=${emmaConvention.metaDataFilePath}", "-Demma.coverage.out.merge=true"
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")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment