-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document a pattern that do not return exit code #1855
Comments
Yes very good point! 👍 Note that the AutoComplete application had this exact same problem and this was solved by using System properties to decide whether to actually call |
Sure thing, I'll make a PR. |
Resolves #1855 Signed-off-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
@ttddyy Thank you for your contribution! I took the liberty to rewrite and add some examples. Again many thanks! |
I have been using picocli on the micrometer-docs-generator project and stumbled upon a problem that
System.exit
halt the maven process when exec-maven-javaexec:java
goal is used.This is because
exec:java
uses the main maven process to invoke the target class andSystem.exit
would simply halt the process that maven runs.It is natural for a standalone CLI application to use the
System.exit
, but code invoked by some other application on the same process will have a problem usingSystem.exit
.For my case, I initially tried to make the app a fat executable jar and make it invoked by
exec:exec
goal which spawns a new process, so it can useSystem.exit
. micrometer-metrics/micrometer-docs-generator#69At the end, instead of the executable jar, I decided to go with simply throwing an exception AFTER
CommandLine#execute
is executed based on the returned exit code.I appreciate this pattern is also documented somewhere.
Since all I see is always using
System.exit
, it would be a problem for the environment whereSystem.exit
causes a negative effect such asexec:java
.The text was updated successfully, but these errors were encountered: