Instead of running a second task to generate another report, you could make the following change to add another report format.
Then grab one of the files and write it to the console.
(You could just grab the HTML or XML report and write that to the console, but it may be hard to read without some formatting.)
Note: The reports
closure will get you reports in different formats. The doLast
will print the output of one of those reports to the console. If you do not need the console output, you can remove the doLast
closure.
I would suggest changing your task like this:
task codenarcConsoleReport {
doLast {
println file("${codenarc.reportsDir}/main.txt").text
}
}
codenarcMain {
finalizedBy codenarcConsoleReport
reports {
text.enabled = true
html.enabled = true
xml {
enabled = true
destination = file("${codenarc.reportsDir}/customFileName.xml")
}
}
}
Note: This will not cause your task to run twice.