cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1393496 - /cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java
Date Wed, 03 Oct 2012 14:02:48 GMT
Author: dkulp
Date: Wed Oct  3 14:02:48 2012
New Revision: 1393496

URL: http://svn.apache.org/viewvc?rev=1393496&view=rev
Log:
Add some extra diagnostics to the java6 compilation

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=1393496&r1=1393495&r2=1393496&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/util/Compiler.java Wed Oct  3 14:02:48
2012
@@ -25,8 +25,11 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.LinkedList;
 import java.util.List;
 
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaCompiler.CompilationTask;
 import javax.tools.JavaFileObject;
@@ -44,10 +47,19 @@ public class Compiler {
     private String encoding;
     private boolean forceFork = Boolean.getBoolean(Compiler.class.getName() + "-fork");
     private File classpathTmpFile;
+    private List<String> errors = new LinkedList<String>();
+    private List<String> warnings = new LinkedList<String>();
     
     public Compiler() {
     }
     
+    public List<String> getErrors() {
+        return errors;
+    }
+    public List<String> getWarnings() {
+        return warnings;
+    }
+    
     public void setMaxMemory(long l) {
         maxMemory = l;
     }
@@ -181,7 +193,28 @@ public class Compiler {
         
         List<String> args = new ArrayList<String>();
         addArgs(args);
-        CompilationTask task = compiler.getTask(null, fileManager, null, args, null, fileList);
+        DiagnosticListener<JavaFileObject> listener = new DiagnosticListener<JavaFileObject>()
{
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                switch (diagnostic.getKind()) {
+                case ERROR:
+                    errors.add(diagnostic.toString());
+                    if (verbose) {
+                        System.err.println(diagnostic.toString());
+                    }
+                    break;
+                case WARNING:
+                case MANDATORY_WARNING:
+                    warnings.add(diagnostic.toString());
+                    if (verbose) {
+                        System.err.println(diagnostic.toString());
+                    }
+                    break;
+                default:
+                    break;
+                }   
+            }
+        };
+        CompilationTask task = compiler.getTask(null, fileManager, listener , args, null,
fileList);
         Boolean ret = task.call();
         try {
             fileManager.close();
@@ -189,6 +222,7 @@ public class Compiler {
             System.err.print("[ERROR] IOException during compiling.");
             e.printStackTrace();
         }
+        
         return ret;
     }
 



Mime
View raw message