gmavenplus:execute How to fail a build

10 views
Skip to first unread message

Mario Jauvin

unread,
Apr 9, 2021, 10:59:27 AM4/9/21
to GMavenPlus
I know it is possible to fail a build when executing a groovy script by throwing a runtime exception but I am wondering if there is another way to do that for the following reasons:

You need to log an error if you want the message to appear using the standard maven logging and when you throw the runtime exception, this creates a very long and confusing error message.

Is it possible to fail the build using a more maven standard way?  I tried System,.exit(1) and that exists immediately, not good.  I tried return(1) but it has not effect.

Mario Jauvin

unread,
Apr 9, 2021, 11:14:29 AM4/9/21
to GMavenPlus
I tried throwing a MojoFailureException or a MojoExecutionException but the result is the same as throwing a runtime exception.

Keegan Witt

unread,
Apr 10, 2021, 9:46:50 PM4/10/21
to Mario Jauvin, GMavenPlus
As far as I'm aware, that is the standard Maven way.  For example, the Maven Surefire plugin throws a MojoExecutionException for fatal test failures, or a MojoFailureException for non-fatal failures.  The closure which the original GMaven plugin used for intentional build failures was MojoExecutionException.  My guess is RuntimeException works too because Maven catches and wraps the exception.catching and wrapping the exception (though I haven't looked at their code to be sure).

-Keegan

--
You received this message because you are subscribed to the Google Groups "GMavenPlus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gmavenplus+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gmavenplus/4eb82e0f-1b85-4b60-be0c-7b75cc10301cn%40googlegroups.com.

Mario Jauvin

unread,
Apr 12, 2021, 8:53:08 PM4/12/21
to Keegan Witt, GMavenPlus
Ok, thanks for the clarification. 
Reply all
Reply to author
Forward
0 new messages