I am attempting to capture some test/verification output of the check task. I have this configuration (using Kotling script):
tasks.check {
doLast {
println("Copying files")
project.copy {
from("build/resources/main/reports/index.html")
into("build/reports/")
}
println("Copied files")
}
Now I would expect this to always copy the specific file but unfortunately, it does nothing if check fails (which kind of defeats the purpose). Very odd semantics that doLast should only execute upon success.
I have seen various posts suggesting to use set ignoreExitValue to true but apparently that isn’t a property of the check task. I’ve also tried creating a separate task to do the job and using finalizedBy to ensure that the custom task executes after check like this:
tasks.check {
finalizedBy("copyReportRoot")
}
tasks.register("copyReportRoot") {
println("Running copyReportRoot...")
doLast {
println("Copying files")
project.copy {
from("build/resources/main/reports/index.html")
into("build/reports/")
}
println("Copied files")
}
}
This also doesn’t run the doLast block upon failure. If I pull the project.copy
block out of doLast
, it runs before check
which again defeats the purpose.
Any help? Thanks!