From: wisberg Date: Wed, 30 Apr 2003 02:03:54 +0000 (+0000) Subject: Usage is now emitted as an abort message, so AjcTask now ignores usage when determin... X-Git-Tag: V1_1_0_RC2~132 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f6d57acb9814d2365ec6ddd9ff290f201c656247;p=aspectj.git Usage is now emitted as an abort message, so AjcTask now ignores usage when determining whether to throw a BuildException after getting an abort message. This fixes 3 tests. --- diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java index 43d66f8f8..f9655b4aa 100644 --- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -179,6 +179,9 @@ public class AjcTask extends MatchingTask { private static final File DEFAULT_DESTDIR = new File("."); + /** do not throw BuildException on fail/abort message with usage */ + private static final String USAGE_SUBSTRING = "AspectJ-specific options"; + /** valid -X[...] options other than -Xlint variants */ private static final List VALID_XOPTIONS; @@ -850,26 +853,37 @@ public class AjcTask extends MatchingTask { // no exceptions for any of the fail/abort messages. // The interceptor message handler should have already // printed the messages, including any stack traces. + // HACK: this ignores the Usage message { IMessage[] fails = holder.getMessages(IMessage.FAIL, true); if (!LangUtil.isEmpty(fails)) { StringBuffer sb = new StringBuffer(); String prefix = "fail due to "; + int numThrown = 0; for (int i = 0; i < fails.length; i++) { + String message = fails[i].getMessage(); + if (LangUtil.isEmpty(message)) { + message = ""; + } else if (-1 != message.indexOf(USAGE_SUBSTRING)) { + continue; + } Throwable t = fails[i].getThrown(); if (null != t) { + numThrown++; sb.append(prefix); sb.append(LangUtil.unqualifiedClassName(t.getClass())); - prefix = ", "; - } + String thrownMessage = t.getMessage(); + if (!LangUtil.isEmpty(thrownMessage)) { + sb.append(" \"" + thrownMessage + "\""); + } + } + sb.append("\"" + message + "\""); + prefix = ", "; } if (0 < sb.length()) { - sb.append(" rendered in messages above."); - } else { - sb.append(fails.length - + " fails/aborts (no exceptions)"); + sb.append(" (" + numThrown + " exceptions)"); + throw new BuildException(sb.toString()); } - throw new BuildException(sb.toString()); } } }