2009-06-23 3 views
35

AbstractMavenMojo의 execute 메소드는 MojoExecutionException 및 MojoFailureException이라는 두 가지 예외를 throw합니다. 이 중 하나를 수행하면 빌드가 중지되고 로그에는 거의 각각이라는 동일한 메시지가 표시됩니다.Maven에서 MojoExecutionException과 MojoFailureException을 비교하는 경우

MojoExecutionException에 대한 메시지는 다음과 같습니다

[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] [exception text] 
[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 

및 MojoFailureException에 대한 메시지는 다음과 같습니다

[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] [exception text] 
[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 

때 어떤 예외 이유를 던져해야합니까?

답변

29

문제가 발생하여 빌드를 계속할 수없는 경우 MojoExecutionException을 던져야하고 그렇지 않은 경우 MojoFailureException을 사용해야합니다.

maven을 실행할 때 MojoFailureExpections을 넘겨 줄 동작을 제어 할 수 있습니다.

다음 링크는 차이점을 자세히 설명합니다 : https://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-custom-plugin.html#writing-plugins-sect-failure
링크가 깨졌습니다. Google 검색 sonatype writing-plugins-sect-custom-plugin writing-plugins-sect-failure

+0

감사합니다. 정확히 내가 무엇을했는지입니다. –

+1

링크가 끊어졌습니다. 대신 http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-custom-plugin.html#writing-plugins-sect-failure를 사용해보십시오. – matsev

+0

@matsev, 나는 링크를 고쳤다. – Gili

관련 문제