Permalink
Browse files

non-working clover integration

  • Loading branch information...
1 parent 93500fd commit eda971b71d800e8afefc11b4eba733c122883995 @graemerocher graemerocher committed Sep 8, 2010
Showing with 164 additions and 0 deletions.
  1. +65 −0 build.gradle
  2. +94 −0 clover.gradle
  3. +5 −0 clover.license
View
@@ -23,6 +23,7 @@ subprojects {
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'maven'
+ apply from: "file:${rootDir}/clover.gradle"
}
def isGormDatasource = project.name.startsWith("grails-datastore-gorm-") && !project.name.endsWith("tck")
@@ -38,6 +39,7 @@ subprojects {
dependencies {
if(isStandardGroovyMavenProject) {
groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.7.4'
+
testCompile 'junit:junit:4.8.1'
testCompile spockDependency
}
@@ -164,4 +166,67 @@ subprojects {
}
}
+}
+
+configurations {
+ build
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ build "com.cenqua.clover:clover:3.0.2"
+ build "org.apache.ant:ant-junit:1.8.1"
+ build "org.apache.ant:ant-nodeps:1.8.1"
+}
+
+task test(dependsOn: getTasksByName("test", true)) << {
+ def reportsDir = "${buildDir}/reports"
+
+ // Aggregate the test results
+ ant.taskdef(
+ name: 'junitreport2',
+ classname: "org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator",
+ classpath: configurations.build.asPath
+ )
+
+ def testReportsDir = new File("${reportsDir}/tests")
+ if (testReportsDir.exists()) {
+ testReportsDir.deleteDir()
+ }
+ testReportsDir.mkdirs()
+
+ ant.junitreport2(todir: testReportsDir) {
+ subprojects.each {
+ def testResultsDir = "${it.buildDir}/test-results"
+ if (new File(testResultsDir).exists()) {
+ fileset(dir: testResultsDir) {
+ include(name: "TEST-*.xml")
+ }
+ }
+ }
+ report(todir: testReportsDir)
+ }
+
+ // Aggregate the coverage results
+ if (project.hasProperty("withClover")) {
+ def db = "clover/clover.db"
+ def mergedDb = "${buildDir}/${db}"
+ def cloverReportsDir = "${reportsDir}/clover"
+ ant.taskdef(resource: "cloverlib.xml", classpath: configurations.build.asPath)
+ ant."clover-merge"(initstring: mergedDb) {
+ subprojects.each {
+ def projectCloverDb = "${it.buildDir}/${db}"
+ if (new File(projectCloverDb).exists()) {
+ cloverdb(initstring: projectCloverDb)
+ }
+ }
+ }
+ ant."clover-report"(initstring: mergedDb) {
+ current(outfile:"${cloverReportsDir}/clover.xml")
+ }
+ ant."clover-html-report"(initstring: mergedDb, outdir:"${cloverReportsDir}/html")
+ }
}
View
@@ -0,0 +1,94 @@
+apply plugin: "groovy"
+
+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 = "/Developer/grails-dev/core/inconsequential/clover.license"
+ }
+}
+
+dependencies {
+ testRuntime "com.cenqua.clover:clover:3.0.2"
+}
+
+test.doFirst {
+ if (project.hasProperty("withClover")) {
+ 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"()
+
+ ant.'clover-setup'(initString: "${buildDir}/clover/clover.db", tmpDir: "${buildDir}/clover/tmp") {
+ ["java", "groovy"].each { source ->
+ ["main", "test"].each { type ->
+ sourceSets."$type"."$source".srcDirs.each {
+ if (it.exists()) {
+ ant.fileset(dir: it) {
+ include(name: "**/*.groovy")
+ include(name: "**/*.java")
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //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.testCompile.asPath
+ }
+ javac(source:sourceCompatibility, target: targetCompatibility) {
+ classpath {
+ pathElement path:configurations.testRuntime.asPath
+ }
+ }
+
+ ["java", "groovy"].each { source ->
+ sourceSets.main."$source".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)
+
+ ant."clover-report" {
+ current(outfile:"${reportsDir}/clover/clover.xml")
+ }
+ ant."clover-html-report"(outdir:"${reportsDir}/clover/html");
+ }
+}
View
@@ -0,0 +1,5 @@
+pmqOPPevJRxewUAoSwGTXaKrPNwRSFgqNRUUNwpFTlvnMC
+mi2KC0BWSj8iuzoLZUtK<49L2K70p6Dqxa0wTtoVPIQuB2
+rqRoTuoqpmNOnopnoOpTUOmonooOQQRnoRUUTvSwvxuvPP
+nmQnmqmUUnottnouummmmmUUnottnouummmmmUU7oXfipU
+Unmmmm

0 comments on commit eda971b

Please sign in to comment.