Define a reporttask
closure in your clover
{} code block to configure advanced report generation options for your Groovy project's build process. Here, you can define various attributes and elements of the clover-report task. In fact, any Clover Ant tasks and their attributes and elements may be used in this closure.
You would not normally include clover-setup tasks in the reporttask
closure because the latter is executed after the clover-setup tasks have executed.
The reporttask
closure is passed the following parameters:
ant
— an instance of a org.codehaus.gant.GantBuilderbinding
— the groovy binding for accessing project variablesplugin
— the clover grails plugin that invoked this closureThe syntax used to define your clover-report tasks or any other valid Ant task in the clover
{} code block is Gant.
The following example clover
{} code block and reporttask
definition in your BuildConfig.groovy
file will:
build/clover/report
subdirectory of your Grails project directory.clover { // reports.dir defines the location of your Clover report output // within your Grails project. reports.dir = "build/clover/report" // The reporttask closure is invoked after all tests have run. reporttask = { ant, binding, plugin -> ant.mkdir(dir: "${clover.reports.dir}") ant.'clover-report' { ant.current(outfile: "${clover.reports.dir}/clover.pdf", summary: true) { format(type: "pdf") } ant.current(outfile: "${clover.reports.dir}") { format(type: "html") ant.columns { lineCount() complexity() filteredElements(format:"bar") uncoveredElements(format: "raw") totalElements(format: "raw") totalPercentageCovered() } } ant.current(outfile: "${clover.reports.dir}/clover.xml") { format(type: "xml") } ant.current(outfile: "${clover.reports.dir}") { format(type: "json") } } plugin.launchReport(clover.reports.dir) }
The reporttask closure could be also used to run other post-build activities, like clover-check or clover-log, for example.
reporttask = { ant, binding, self -> ant.'clover-check'(target: "80%", haltOnFailure: true) { } }