Index: src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java --- a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java (revision Staged) +++ b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java (date 1746850617794) @@ -293,11 +293,14 @@ .getThreadGroup() .uncaughtException(Thread.currentThread(), exceptionToReport); } catch (SystemExitException systemExitException) { - if (systemExitException.getExitCode() != 0) { - getLog().error(systemExitException.getMessage()); - throw systemExitException; - } else { - getLog().info(systemExitException.getMessage()); + handleSystemExitException(systemExitException); + } catch (ExceptionInInitializerError exceptionInInitializerError) { + if (exceptionInInitializerError.getCause() instanceof SystemExitException) { + handleSystemExitException((SystemExitException) exceptionInInitializerError.getCause()); + } else { // just pass it on + Thread.currentThread() + .getThreadGroup() + .uncaughtException(Thread.currentThread(), exceptionInInitializerError); } } catch (Throwable e) { // just pass it on Thread.currentThread().getThreadGroup().uncaughtException(Thread.currentThread(), e); @@ -353,6 +356,15 @@ registerSourceRoots(); } + private void handleSystemExitException(SystemExitException systemExitException) { + if (systemExitException.getExitCode() != 0) { + getLog().error(systemExitException.getMessage()); + throw systemExitException; + } else { + getLog().info(systemExitException.getMessage()); + } + } + private void doExec(final String bootClassName) throws Throwable { Class bootClass = Thread.currentThread().getContextClassLoader().loadClass(bootClassName); MethodHandles.Lookup lookup = MethodHandles.lookup();