cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1509784 - /cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
Date Fri, 02 Aug 2013 17:25:58 GMT
Author: dkulp
Date: Fri Aug  2 17:25:58 2013
New Revision: 1509784

URL: http://svn.apache.org/r1509784
Log:
If there is a severe error, make sure we fail the build.

Modified:
    cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java

Modified: cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java?rev=1509784&r1=1509783&r2=1509784&view=diff
==============================================================================
--- cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
(original)
+++ cxf/xjc-utils/trunk/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
Fri Aug  2 17:25:58 2013
@@ -135,10 +135,14 @@ public abstract class AbstractXSDToJavaM
     
     class Listener extends XJCListener {
         private final List<File> errorfiles;
-
+        private Exception firstError;
+        
         Listener(List<File> errorfiles) {
             this.errorfiles = errorfiles;
         }
+        public Exception getFirstError() {
+            return firstError;
+        }
 
         public void error(SAXParseException exception) {
             final String sysId = exception.getSystemId();
@@ -185,12 +189,16 @@ public abstract class AbstractXSDToJavaM
                         }
                     };
                 }
-            }                        
+            }                     
             return file;
         }
 
         public void fatalError(SAXParseException exception) {
             error(exception);
+            if (firstError == null) {
+                firstError = exception;
+                firstError.fillInStackTrace();
+            }
         }
 
         public void warning(SAXParseException exception) {
@@ -322,11 +330,15 @@ public abstract class AbstractXSDToJavaM
                         removeMessages(xsdOptions[x].getXsd());
                         removeMessages(xsdOptions[x].getBindingFile());
                         
-                        int i = com.sun.tools.xjc.Driver.run(args, new Listener(errorFiles));
+                        Listener listener = new Listener(errorFiles);
+                        int i = com.sun.tools.xjc.Driver.run(args, listener);
                         if (i == 0) {
                             doneFile.delete();
                             doneFile.createNewFile();
+                        } else if (listener.getFirstError() != null) {
+                            throw listener.getFirstError();
                         }
+                        System.out.println("Result: " + i);
                         File dirs[] = xsdOptions[x].getDeleteDirs();
                         if (dirs != null) {
                             for (int idx = 0; idx < dirs.length; ++idx) {



Mime
View raw message