You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/06/05 12:43:29 UTC

[uima-uimafit] branch bugfix/UIMA-6242-uimaFIT-Maven-plugin-should-fail-on-error-by-default created (now 6a3ef63)

This is an automated email from the ASF dual-hosted git repository.

rec pushed a change to branch bugfix/UIMA-6242-uimaFIT-Maven-plugin-should-fail-on-error-by-default
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git.


      at 6a3ef63  [UIMA-6242] uimaFIT Maven plugin should fail on error by default

This branch includes the following new commits:

     new 6a3ef63  [UIMA-6242] uimaFIT Maven plugin should fail on error by default

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[uima-uimafit] 01/01: [UIMA-6242] uimaFIT Maven plugin should fail on error by default

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch bugfix/UIMA-6242-uimaFIT-Maven-plugin-should-fail-on-error-by-default
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git

commit 6a3ef6356d6b9208027988d403ee9d3186cd7c8d
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Fri Jun 5 14:43:11 2020 +0200

    [UIMA-6242] uimaFIT Maven plugin should fail on error by default
    
    - Added "failOnError" parameter
    - By default fail on errors
---
 .../uima/fit/maven/GenerateDescriptorsMojo.java    | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
index c616d84..2e85b4b 100644
--- a/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
+++ b/uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/GenerateDescriptorsMojo.java
@@ -80,6 +80,12 @@ public class GenerateDescriptorsMojo extends AbstractMojo {
   @Parameter(defaultValue = "${project.build.sourceEncoding}", required = true)
   private String encoding;
 
+  /**
+   * Fail on error.
+   */
+  @Parameter(defaultValue = "true", required = true)
+  private boolean failOnError;
+
   enum TypeSystemSerialization {
     NONE, EMBEDDED
   }
@@ -162,13 +168,13 @@ public class GenerateDescriptorsMojo extends AbstractMojo {
           componentsManifest.append("classpath*:").append(clazzPath + ".xml").append('\n');
         }
       } catch (SAXException e) {
-        getLog().warn("Cannot serialize descriptor for [" + clazzName + "]", e);
+        handleError("Cannot serialize descriptor for [" + clazzName + "]", e);
       } catch (IOException e) {
-        getLog().warn("Cannot write descriptor for [" + clazzName + "]", e);
+        handleError("Cannot write descriptor for [" + clazzName + "]", e);
       } catch (ClassNotFoundException e) {
-        getLog().warn("Cannot analyze class [" + clazzName + "]", e);
+        handleError("Cannot analyze class [" + clazzName + "]", e);
       } catch (ResourceInitializationException e) {
-        getLog().warn("Cannot generate descriptor for [" + clazzName + "]", e);
+        handleError("Cannot generate descriptor for [" + clazzName + "]", e);
       } finally {
         Thread.currentThread().setContextClassLoader(classLoader);
       }
@@ -185,12 +191,20 @@ public class GenerateDescriptorsMojo extends AbstractMojo {
       try {
         FileUtils.fileWrite(path.getPath(), encoding, componentsManifest.toString());
       } catch (IOException e) {
-        throw new MojoExecutionException("Cannot write components manifest to [" + path + "]"
+        handleError("Cannot write components manifest to [" + path + "]"
                 + ExceptionUtils.getRootCauseMessage(e), e);
       }
     }
   }
 
+  private void handleError(String message, Exception e) throws MojoExecutionException {
+    if (failOnError) {
+      throw new MojoExecutionException(message, e);
+    }
+
+    getLog().error(message, e);
+  }
+
   private void embedTypeSystems(ProcessingResourceMetaData metadata)
           throws ResourceInitializationException {
     TypeSystemDescriptionFactory.forceTypeDescriptorsScan();