-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-7351] clarify differences between MojoFailureException and MojoExecutionException in javadoc #632
base: master
Are you sure you want to change the base?
Conversation
MojoExecutionException in javadoc
1c69460
to
941f82e
Compare
@kwin I think it would be interesting to add pointers to the code where those exceptions are actually handled ? I must admit I tried to find them but I haven't been able to find them in a timely manner. For example there's no |
@gnodet Indeed I couldn't find anything either yet. TBH I have just taken the information from https://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-custom-plugin.html#writing-plugins-sect-failure which I consider a pretty reliable source. But maybe the different handling of those exceptions has vanished over time. Will do some more tests.... |
I tried it out with a dummy mojo and both exceptions behave exactly the same, i.e. both emit "BUILD FAILURE". I couldn't influence the build outcome with any of the |
Given that, I would recommend to either reestablish the different semantics or deprecate one exception class of the two. In any case right now it is highly confusing why there are two different exception classes and when to use which in mojos. |
Dug a bit deeper and found maven/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Lines 235 to 255 in ed370a6
|
Now, the exceptions are handled in |
My understanding was that MojoExecutionException is a wrapper around another exception as primary usage whereas MojoFailureException is a root exception by itself (and previous handling tends to confirm it). Overall the need of these exception is that mojo don't throw an Exception/Throwable but there is no technical reason - in particular now, so ultimately we can just deprecate both and change mojo contract for 4.0, no? |
I think the reason is to throw an exception which would allow Maven to continue (by using |
@kwin not sure, |
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.