Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 48041 invoked from network); 14 Jun 2009 18:10:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jun 2009 18:10:15 -0000 Received: (qmail 488 invoked by uid 500); 14 Jun 2009 18:10:26 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 412 invoked by uid 500); 14 Jun 2009 18:10:26 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 401 invoked by uid 99); 14 Jun 2009 18:10:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 18:10:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jun 2009 18:10:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8C3592388892; Sun, 14 Jun 2009 18:10:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@felix.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090614181001.8C3592388892@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 errors; + private final boolean strictMode; + + private final List errors = new ArrayList(); - private final List warnings; + private final List warnings = new ArrayList(); public IssueLog(final boolean strictMode) { - this.errors = new ArrayList(); - if ( strictMode ) { - this.warnings = this.errors; - } else { - this.warnings = new ArrayList(); - } + 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 getErrors() { - return this.errors; + public void addWarning(final String e) { + warnings.add(e); } - @SuppressWarnings("unchecked") - public List 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)"); }