Reputation: 520
I have a problem where maven is stuck at the very end of testing.
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.235 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
But the BUILD SUCCESSFUL
message is not showing up.
Why?
Upvotes: 2
Views: 602
Reputation: 520
I found that we were using
Process proc = new ProcessBuilder("cmd", "/C", "start", "/B", "notepad").start();
to start an outside application. That application is tied to the java process. The java process will not terminate until that outside application is terminated as well. Even with all of this cmd/start magic, windows and Java would not separate the processes. After reading a ton of blogs and websites, they all suggested the same thing. Flush the output buffers, and read in all of the STD ERR and STD OUT steams. Still, this did not work. Java still said, "There's still an app running!"
The answer, was to make sure that java had no idea the app was running. I did this, by using
Process proc = new ProcessBuilder("rundll32", "SHELL32.DLL,ShellExec_RunDLL", "notepad").start();
In this method, java calls rundll32 and that uses the SHELL32 DLL function ShellExec_RunDLL to start the app. Java does not detect this new "notepad" process, and RunDLL32 exits almost immediately. I also followed all of the proper ways to flush the output and grab the STD OUT and STD ERR of rundll32.
The background app, notepad, was able to run just fine, and maven finished as expected.
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.935 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Mon Mar 18 11:28:54 PDT 2013
[INFO] Final Memory: 27M/72M
[INFO] ------------------------------------------------------------------------
Upvotes: 2