Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven "catch" execution - execute cleanup on failed build

Tags:

java

maven

I have a maven build the launches a process (a database) using the exec plugin, then interacts with that process using several other plugin executions (the maven sql mojo) and then finally shuts down that process, using a 2nd execution od the exec plugin, bound to a later phase.

right now if any of the "middle" executions fail im left with a running process, which the build started but didnt get around to shutting down.

is there any "try/finally" mechanism in maven which i can use to clean up after a botched build?

like image 913
radai Avatar asked Nov 12 '22 03:11

radai


1 Answers

Maybe, if you're using this workflow for testing, you could use test plugin like surefire or failsafe to prevent failing of your build process. And validate results after database if down. In short, start db in pre-test phase, run tests in separate process using plugins I've mentioned above, stop db in port-test phase and validate test results in verify? phase.

Failsafe plugin

like image 156
Stanislav Levental Avatar answered Nov 14 '22 22:11

Stanislav Levental