This is the documentation for Clover 3.3. View this page for the

Unknown macro: {spacejump}

of Clover, or visit the latest Clover documentation.

Define a setuptask 'closure' in your clover {} code block to configure advanced options for your Groovy project's build processes. Here, you can define various attributes and elements of the clover-setup task.

The setuptask closure is passed the following parameters:

  • ant — an instance of a org.codehaus.gant.GantBuilder
  • binding — the groovy binding for accessing project variables
  • plugin — the clover grails plugin that invoked this closure

The syntax used to define your clover-setup tasks in the clover {} code block is Gant.

Please be aware that some attributes and sub-elements of the clover-setup task do not support Groovy. Therefore, if your Grails project makes substantial use of Groovy code (as opposed to pure Java code, which is likely to be the case), not all features of the clover-setup task will be available to you. Refer to the clover-setup topic for details.

 

Example: using custom clover.db location and set of files to be instrumented

clover {
    // Example setuptask closure that will be invoked to configure clover.
    // Any Clover initialisation tasks should be defined here.
    // All attributes on the ant clover-setup task, which are
    // supported by your source code, can be defined here.

    setuptask = { ant, binding, plugin ->
        ant.'clover-setup'(initstring: "${binding.projectWorkDir}/clover/custom/clover.db") {
            ant.fileset(dir: "grails-app", includes: "**/*.groovy") { }
        }
    }
} 

 

Example: enabling distributed coverage

clover {
    setuptask = { ant, binding, plugin -> 
        ant.'clover-setup'(initstring: "${binding.projectWorkDir}/clover/db/clover.db", 
                       tmpDir: "${binding.projectWorkDir}/clover/tmp") {
            distributedCoverage(port: 7777, host: "localhost", timeout: 5000, numClients: 0)
        }
    }
}

 

Example: using shared coverage recorder

Use the Shared Coverage Recorder only in case when you have performance problem related with creation of thousands of coverage recording files in clover.db directory. See Coverage Recorders for more details.

clover {
    setuptask = { ant, binding, plugin -> 
        ant.delete(dir: "target/clover/db")
        ant.delete(dir: "target/clover/tmp")
        ant.'clover-setup'(initstring: "target/clover/db/clover.db", 
                           tmpDir: "target/clover/tmp") {
            ant.profiles {
                ant.profile(name: "default", coverageRecorder: "SHARED")
            } 
        }
    }
    reporttask =  { ant, binding, plugin ->
        ant.delete(dir: "target/clover/report")
        ant.'clover-report'(initstring: "target/clover/db/clover.db") {
            ant.current(outfile: "target/clover/report/clover.xml") {
                ant.format(type: "xml")
            }
            ant.current(outfile: "target/clover/report") {
                ant.format(type: "html")
            }
        }
    }
 }

 

 

  • No labels