abhi
abhi

Reputation: 53

Force execute taskReport on build failures?

Gradle 1.4 has new test report aggregate task: http://www.gradle.org/docs/current/release-notes#stand-alone-test-report-task

task testReport(type: TestReport) {
    destinationDir = file("$buildDir/reports/all-tests")
    reportOn subprojects*.test
}

Is there a way to make this task run even when build fails? Currently if I do:

taskReport.dependsOn test
build.dependsOn taskReport

it executes only if build is success.

Upvotes: 2

Views: 600

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123910

Good news first: Upcoming enhancements to Gradle's task model, currently scheduled for Gradle 1.6, will address this and similar use cases.

Meanwhile, the possibilities are limited. One option is to run with --continue, although this will continue with other tasks as well. Another potential option is to register a org.gradle.api.execution.TaskExecutionListener (via gradle.project.addListener()) and have it call testReport.generateReport() after a Test task has failed. Although calling a task directly is heavily discouraged (and often won't produce the expected behavior), it might do as a temporary workaround in this particular case.

Upvotes: 2

Related Questions