We have some unit tests that unfortunately create memory-mapped NIO files that cannot be deleted by the process that created them (some windows issue).
Regardless, I would like to run some sort of clean up after these tests, whether they passed or not. I was going to run a small ant script at the prepare-package phase, but if any test fails, surefire exits immediately.
Apart from going to the failsafe plugin which has a post-test phase, is there any clever way I can run my cleanup regardless of pass or fail?
I suspect not - I've gone through all the surefire config options...
edit: memory-mapped nio files cannot be deleted in the same process, even by deleteOnExit.
Add following dependancy in pom and remove existing from your POM
I would make sure the files are created in either
target/
or the OS's temporary directory (usingSystem.getProperty("java.io.tmpdir")
. Then they will be cleaned up automatically when you runmvn clean
, or eventually by the OS.You should bound the thing you want to do into the post-integration-test lifecycle phase which is running afterwards the integration-test phase which is handled by the maven-failsafe-plugin. It might work if you configure the maven-clean-plugin to do so.