Skip to content

Instantly share code, notes, and snippets.

@bluepapa32
Created June 17, 2011 03:44
Show Gist options
  • Save bluepapa32/1030834 to your computer and use it in GitHub Desktop.
Save bluepapa32/1030834 to your computer and use it in GitHub Desktop.
Gradle で Cobertura してみる
configurations{
cobertura
}
dependencies {
cobertura "net.sourceforge.cobertura:cobertura:1.9.4.1"
}
tmpDir = new File(buildDir, "tmp")
coberturaReportDirName = "cobertura"
coberturaReportDir = new File(reportsDir, coberturaReportDirName)
coberturaTmpDirName = "cobertura"
coberturaTmpDir = new File(tmpDir, coberturaTmpDirName)
coberturaInstrDirName = "instr"
coberturaInstrDir = new File(coberturaTmpDir, coberturaInstrDirName)
coberturaMetaDataFileName = "cobertura.ser"
coberturaMetaDataFile = new File(coberturaTmpDir, coberturaMetaDataFileName)
test {
jvmArgs "-Dnet.sourceforge.cobertura.datafile=${coberturaMetaDataFile}"
doFirst {
ant {
taskdef(resource: 'tasks.properties',
classpath: configurations.cobertura.asPath)
'cobertura-instrument'(todir: coberturaInstrDir,
datafile:coberturaMetaDataFile) {
fileset(dir: sourceSets.main.classesDir)
}
}
classpath = files("${coberturaInstrDir}") + configurations.cobertura + classpath
}
doLast {
ant {
'cobertura-report'(destdir: coberturaReportDir,
datafile:coberturaMetaDataFile,
format:'xml') {
sourceSets.main.allJava.srcDirs.each { fileset(dir: it) }
}
'cobertura-report'(destdir: coberturaReportDir,
datafile:coberturaMetaDataFile,
format:'html') {
sourceSets.main.allJava.srcDirs.each { fileset(dir: it)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment