Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created June 13, 2011 16:49
Show Gist options
  • Save bluepapa32/1023156 to your computer and use it in GitHub Desktop.
Save bluepapa32/1023156 to your computer and use it in GitHub Desktop.
Gradle で EMMA してみる
configurations {
emma
}
dependencies {
emma "emma:emma:2.1.5320"
emma "emma:emma_ant:2.1.5320"
}
tmpDir = new File(buildDir, "tmp")
emmaReportDirName = "emma"
emmaReportDir = new File(reportsDir, emmaReportDirName)
emmaTmpDirName = "emma"
emmaTmpDir = new File(tmpDir, emmaTmpDirName)
emmaInstrDirName = "instr"
emmaInstrDir = new File(emmaTmpDir, emmaInstrDirName)
emmaMetaDataFileName = "metadata.em"
emmaMetaDataFile = new File(emmaTmpDir, emmaMetaDataFileName)
test{
jvmArgs "-Demma.coverage.out.file=${emmaMetaDataFile}",
"-Demma.coverage.out.merge=true",
"-Demma.rt.control=false"
doFirst {
ant.taskdef(resource: "emma_ant.properties",
classpath: configurations.emma.asPath)
ant.emma {
instr(instrpath: "${sourceSets.main.classesDir}",
destdir: "${emmaInstrDir}",
metadatafile: "${emmaMetaDataFile}",
merge: "true")
}
classpath = files(emmaInstrDir) + configurations.emma + classpath
}
doLast {
ant.emma {
report {
infileset(file: "${emmaMetaDataFile}")
sourcepath {
sourceSets.main.java.srcDirs.each { pathelement(location: "${it}") }
}
txt(outfile: "${emmaReportDir}/coverage.txt")
html(outfile: "${emmaReportDir}/coverage.html")
xml(outfile: "${emmaReportDir}/coverage.xml")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment