You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Tibor Digana <ti...@apache.org> on 2022/03/13 14:29:01 UTC

The build status in Maven 3.x and MOJO exceptions in Maven Plugin API 3.x

Hello Maven developers,

I want to inform you about some compliance issues between the Javadoc of
Maven Plugin API and the Maven Core 3.x behavior. I am only a messenger
providing the facts and I would like the community to post the opinions and
finally a concrete fix(es).

The Maven 3 reports with info log in case of MOJO throws Mojo exception
[INFO] BUILD FAILURE

The Maven 2 reports with error log in case of MOJO throws Mojo exception:
[ERROR] BUILD ERROR
[ERROR] BUILD FAILURE

Maven 3 is not compliant with the Javadoc in Maven Plugin API 3.8.4 which
says the following:

[1] Javadoc in MojoExecutionException:
"An exception occurring during the execution of a plugin (such as a
compilation failure).
Throwing this exception causes a "BUILD FAILURE" message to be displayed."

[2] Javadoc in MojoFailureException:
"An exception occurring during the execution of a plugin.
Throwing this exception causes a "BUILD ERROR" message to be displayed."

For me the wording in the API matters.
Personally, I agree with the name of the class MojoFailureException which
contains "Failure" and the wording of the build status correctly
corresponds to "BUILD FAILURE".
If this wording relation exists, it looks like it is an intended rule, but
the other exception MojoExecutionException does not match this rule because
no such BUILD EXECUTION exists of course.

Regarding the OOP inheritance current diagram looks like this:
MojoExecutionException extends AbstractMojoExecutionException
MojoFailureException extends AbstractMojoExecutionException

For me, a fix in the class inheritance could be compliant with "BUILD
FAILURE"  if the MojoExecutionException was a type of MojoFailureException,
and a certain inheritance diagram with more sub-exceptions and one
super-exception. Just my proposal:
MojoExecutionException extends MojoFailureException.

Perhaps the Javadoc should be fixed, perhaps the inheritance or the build
status, log level, not sure, just opening the questions for the audience.

[1]:
https://maven.apache.org/ref/3.8.4/maven-plugin-api/apidocs/org/apache/maven/plugin/MojoExecutionException.html


[2]:
https://maven.apache.org/ref/3.8.4/maven-plugin-api/apidocs/org/apache/maven/plugin/MojoFailureException.html


Cheers
Tibor

Re: The build status in Maven 3.x and MOJO exceptions in Maven Plugin API 3.x

Posted by Hervé BOUTEMY <he...@free.fr>.
Olivier opened a Jira issue about this [1]

let's work here

Regards,

Hervé

[1] https://issues.apache.org/jira/browse/MNG-7430

Le dimanche 13 mars 2022, 15:29:01 CET Tibor Digana a écrit :
> Hello Maven developers,
> 
> I want to inform you about some compliance issues between the Javadoc of
> Maven Plugin API and the Maven Core 3.x behavior. I am only a messenger
> providing the facts and I would like the community to post the opinions and
> finally a concrete fix(es).
> 
> The Maven 3 reports with info log in case of MOJO throws Mojo exception
> [INFO] BUILD FAILURE
> 
> The Maven 2 reports with error log in case of MOJO throws Mojo exception:
> [ERROR] BUILD ERROR
> [ERROR] BUILD FAILURE
> 
> Maven 3 is not compliant with the Javadoc in Maven Plugin API 3.8.4 which
> says the following:
> 
> [1] Javadoc in MojoExecutionException:
> "An exception occurring during the execution of a plugin (such as a
> compilation failure).
> Throwing this exception causes a "BUILD FAILURE" message to be displayed."
> 
> [2] Javadoc in MojoFailureException:
> "An exception occurring during the execution of a plugin.
> Throwing this exception causes a "BUILD ERROR" message to be displayed."
> 
> For me the wording in the API matters.
> Personally, I agree with the name of the class MojoFailureException which
> contains "Failure" and the wording of the build status correctly
> corresponds to "BUILD FAILURE".
> If this wording relation exists, it looks like it is an intended rule, but
> the other exception MojoExecutionException does not match this rule because
> no such BUILD EXECUTION exists of course.
> 
> Regarding the OOP inheritance current diagram looks like this:
> MojoExecutionException extends AbstractMojoExecutionException
> MojoFailureException extends AbstractMojoExecutionException
> 
> For me, a fix in the class inheritance could be compliant with "BUILD
> FAILURE"  if the MojoExecutionException was a type of MojoFailureException,
> and a certain inheritance diagram with more sub-exceptions and one
> super-exception. Just my proposal:
> MojoExecutionException extends MojoFailureException.
> 
> Perhaps the Javadoc should be fixed, perhaps the inheritance or the build
> status, log level, not sure, just opening the questions for the audience.
> 
> [1]:
> https://maven.apache.org/ref/3.8.4/maven-plugin-api/apidocs/org/apache/maven
> /plugin/MojoExecutionException.html
> 
> 
> [2]:
> https://maven.apache.org/ref/3.8.4/maven-plugin-api/apidocs/org/apache/maven
> /plugin/MojoFailureException.html
> 
> 
> Cheers
> Tibor





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org