Package org.codehaus.mojo.exec
Class SystemExitManager
java.lang.Object
org.codehaus.mojo.exec.SystemExitManager
Will be used by
BlockExitTransformer to replace System.exit(int) by this implementation.- Author:
- Alexander Kriegisch
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexit(int status) Always throws aSystemExitExceptionwhenSystem.exit(int)is called, instead of terminating the JVM.
-
Method Details
-
exit
public static void exit(int status) Always throws aSystemExitExceptionwhenSystem.exit(int)is called, instead of terminating the JVM.The exception is meant to be handled in the
exec:javagoal. On the one hand, this avoids that Java code called in process can terminate the JVM and the whole Maven build process with it. On the other hand, the exception handler can also differentiate between exit status 0 (OK) and non-0 (error) by inspectingSystemExitException.getExitCode():-
Exit status 0 (OK): Just log the fact that
System.exit(int)was called. - Exit status non-0 (error): In addition to logging, the exception is also passed on, failing the mojo execution as if the called Java code had terminated with an exception instead of trying to terminate the JVM with an error code.
- Parameters:
status- the exit status
-
Exit status 0 (OK): Just log the fact that
-