felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r784593 - in /felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin: IssueLog.java SCRDescriptorMojo.java
Date Sun, 14 Jun 2009 18:10:01 GMT
Author: cziegeler
Date: Sun Jun 14 18:10:01 2009
New Revision: 784593

URL: http://svn.apache.org/viewvc?rev=784593&view=rev
Log:
FELIX-1229 : Correct handling of errors and warnings 

Modified:
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java
    felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java?rev=784593&r1=784592&r2=784593&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/IssueLog.java Sun Jun 14
18:10:01 2009
@@ -18,47 +18,55 @@
  */
 package org.apache.felix.scrplugin;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.logging.Log;
 
 /**
  * Utility class for handling errors and warnings
  */
 public class IssueLog {
 
-    private final List<String> errors;
+    private final boolean strictMode;
+
+    private final List<String> errors = new ArrayList<String>();
 
-    private final List<String> warnings;
+    private final List<String> warnings = new ArrayList<String>();
 
     public IssueLog(final boolean strictMode) {
-        this.errors = new ArrayList<String>();
-        if ( strictMode ) {
-            this.warnings = this.errors;
-        } else {
-            this.warnings = new ArrayList<String>();
-        }
+        this.strictMode = strictMode;
     }
 
-    public void addError(final String e) {
-        errors.add(e);
+    public int getNumberOfErrors() {
+        return this.errors.size();
     }
 
-    public void addWarning(final String e) {
-        warnings.add(e);
+    public boolean hasErrors() {
+        return errors.size() > 0 || (this.strictMode && warnings.size() > 0
);
     }
 
-    public int getNumberOfErrors() {
-        return this.errors.size();
+    public void addError(final String e) {
+        errors.add(e);
     }
 
-    public List<String> getErrors() {
-        return this.errors;
+    public void addWarning(final String e) {
+        warnings.add(e);
     }
 
-    @SuppressWarnings("unchecked")
-    public List<String> getWarnings() {
-        if ( this.errors == this.warnings ) {
-            return Collections.EMPTY_LIST;
+    public void log(final Log log) {
+        // now log warnings and errors (warnings first)
+        // in strict mode everything is an error!
+        for(String warn : warnings) {
+            if ( strictMode ) {
+                log.error(warn);
+            } else {
+                log.warn(warn);
+            }
         }
-        return this.warnings;
+        for(String err : errors) {
+            log.error(err);
+        }
+
     }
 }

Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java?rev=784593&r1=784592&r2=784593&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
(original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
Sun Jun 14 18:10:01 2009
@@ -254,16 +254,11 @@
             }
         }
 
-        // now log warnings and errors (warnings first)
-        for(String warn : iLog.getWarnings()) {
-            this.getLog().warn(warn);
-        }
-        for(String err : iLog.getErrors()) {
-            this.getLog().error(err);
-        }
+        // log issues
+        iLog.log(this.getLog());
 
         // after checking all classes, throw if there were any failures
-        if (iLog.getNumberOfErrors() > 0 ) {
+        if ( iLog.hasErrors() ) {
             throw new MojoFailureException("SCR Descriptor parsing had failures (see log)");
         }
 



Mime
View raw message