Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 54d9aea057
Fetching contributors…

Cannot retrieve contributors at this time

84 lines (72 sloc) 2.887 kb
def cloverConvention = new CloverPluginConvention(project)
project.convention.plugins.clover = cloverConvention
class CloverPluginConvention {
def classesBackupDir
def licenseFile
def clover(Closure close) {
close.delegate = this
close.run()
}
CloverPluginConvention(Project project) {
classesBackupDir = "${project.sourceSets.main.classesDir}-bak"
licenseFile = "/Users/eric/clover.license"
}
}
dependencies {
testRuntime group: 'com.cenqua.clover', name: 'clover', version: '3.0.2'
testRuntime group: 'org.apache.ant', name: 'ant-junit', version: '1.8.1'
testRuntime group: 'org.apache.ant', name: 'ant-nodeps', version: '1.8.1'
}
test.doFirst {
if (project.hasProperty("withClover") && sourceSets.main.classesDir.exists()) {
ant.taskdef(name: 'groovyc', classname:"org.codehaus.groovy.ant.Groovyc", classpath:configurations.testRuntime.asPath)
ant.taskdef(resource:"cloverlib.xml", classpath:configurations.testRuntime.asPath)
ant.property(name:"clover.license.path", value:cloverConvention.licenseFile)
ant."clover-clean"()
//Setup clover recordings
ant.'clover-setup'(initString: "${buildDir}/clover/clover.db", tmpDir: "${buildDir}/clover/tmp") {
["main", "test"].each { type ->
sourceSets."$type".groovy.srcDirs.each {
if (it.exists()) {
ant.fileset(dir: it) {
include(name: "**/*.groovy")
}
}
}
}
}
//move original classes
ant.move(file:sourceSets.main.classesDir, tofile:cloverConvention.classesBackupDir)
//compile instrumented classes
sourceSets.main.classesDir.mkdirs()
ant.groovyc(
destdir:sourceSets.main.classesDir,
fork: true,
verbose: true) {
classpath {
pathElement path:configurations.testRuntime.asPath
}
sourceSets.main.groovy.srcDirs.each {
if (it.exists()) {
src(path: it)
}
}
}
//copy resources
ant.copy(todir:sourceSets.main.classesDir) {
fileset(dir:cloverConvention.classesBackupDir, excludes:"**/*.class")
}
}
}
test.doLast {
if (project.hasProperty("withClover") && new File(cloverConvention.classesBackupDir).exists()) {
// restore original classes
ant.delete(file: sourceSets.main.classesDir)
ant.move(file:cloverConvention.classesBackupDir, tofile:sourceSets.main.classesDir)
def cloverReportsDir = "${reportsDir}/clover"
ant."clover-report" {
current(outfile:"${cloverReportsDir}/clover.xml")
}
ant."clover-html-report"(outdir:"${cloverReportsDir}/html");
}
}
Jump to Line
Something went wrong with that request. Please try again.