]> source.dussan.org Git - aspectj.git/commitdiff
Usage is now emitted as an abort message, so AjcTask now ignores usage when determin...
authorwisberg <wisberg>
Wed, 30 Apr 2003 02:03:54 +0000 (02:03 +0000)
committerwisberg <wisberg>
Wed, 30 Apr 2003 02:03:54 +0000 (02:03 +0000)
taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java

index 43d66f8f8b25908eb8aeb9bd412e9301553c2aa1..f9655b4aa36cb17bbc6ae779b362ddf852fae07b 100644 (file)
@@ -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 = "<no 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());
             }
         }
     }