List of usage examples for org.aspectj.bridge IMessage FAIL
Kind FAIL
To view the source code for org.aspectj.bridge IMessage FAIL.
Click Source Link
From source file:AjcCompiler.java
License:Open Source License
/** * Hook into the maven logger.//from w ww . j av a 2s . c om */ public boolean handleMessage(IMessage message) { if (message.getKind().equals(IMessage.WARNING) && !isIgnoring(IMessage.WARNING)) log.warning(message.getMessage()); else if (message.getKind().equals(IMessage.DEBUG) && !isIgnoring(IMessage.DEBUG)) log.fine(message.getMessage()); else if (message.getKind().equals(IMessage.ERROR) && !isIgnoring(IMessage.ERROR)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.ABORT) && !isIgnoring(IMessage.ABORT)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.FAIL) && !isIgnoring(IMessage.FAIL)) log.severe(message.getMessage()); else if (message.getKind().equals(IMessage.INFO) && !isIgnoring(IMessage.INFO)) log.fine(message.getMessage()); else if (message.getKind().equals(IMessage.WEAVEINFO) && !isIgnoring(IMessage.WEAVEINFO)) log.info(message.getMessage()); else if (message.getKind().equals(IMessage.TASKTAG) && !isIgnoring(IMessage.TASKTAG)) log.fine(message.getMessage()); return super.handleMessage(message); }
From source file:de.zalando.mojo.aspectj.MavenMessageHandler.java
License:Open Source License
/** * Copies output from the supplied message onto the active Maven Log. * If the message type (i.e. {@code message.getKind()}) is listed in the showDetailsForMessageKindList List, * the message is prefixed with location details (Class, row/line number etc.) as well. * <p/>//from w ww .j a v a 2s.c o m * {@inheritDoc} */ public boolean handleMessage(final IMessage message) { // Compose the message text final StringBuilder builder = new StringBuilder(message.getMessage()); if (isMessageDetailDesired(message)) { // // The AJC details are typically delivered on the format [fileName]:[lineNumber] // (i.e. /src/main/java/Clazz.java:16). // // Mimic this, and include the context of the message as well, // including guarding against NPEs. // final ISourceLocation sourceLocation = message.getSourceLocation(); final String sourceFile = sourceLocation == null || sourceLocation.getSourceFile() == null ? "<unknown source file>" : sourceLocation.getSourceFile().getAbsolutePath(); final String context = sourceLocation == null || sourceLocation.getContext() == null ? "" : sourceLocation.getContext() + "\n"; final String line = sourceLocation == null ? "<no line information>" : "" + sourceLocation.getLine(); builder.append("\n\t").append(sourceFile).append(":").append(line).append("\n").append(context); } final String messageText = builder.toString(); if (isNotIgnored(message, IMessage.DEBUG) || isNotIgnored(message, IMessage.INFO) || isNotIgnored(message, IMessage.TASKTAG)) { // The DEBUG, INFO, and TASKTAG ajc message kinds are considered Maven Debug messages. log.debug(messageText); } else if (isNotIgnored(message, IMessage.WEAVEINFO)) { // The WEAVEINFO ajc message kind is considered Maven Info messages. log.info(messageText); } else if (isNotIgnored(message, IMessage.WARNING)) { // The WARNING ajc message kind is considered Maven Warn messages. log.warn(messageText); } else if (isNotIgnored(message, IMessage.ERROR) || isNotIgnored(message, IMessage.ABORT) || isNotIgnored(message, IMessage.FAIL)) { // We map ERROR, ABORT, and FAIL ajc message kinds to Maven Error messages. log.error(messageText); } // Delegate to normal handling. return super.handleMessage(message); }
From source file:org.eclipse.ajdt.core.ant.AjcTask.java
License:Open Source License
/** * Run the compile in the same VM by loading the compiler (Main), setting up any message holders, doing the compile, and * converting abort/failure and error messages to BuildException, as appropriate. * /*from ww w . ja v a2s . co m*/ * @return true on successful compilation * @throws BuildException if abort or failure messages or if errors and failonerror. * */ protected boolean executeInSameVM(String[] args) { if (null != maxMem) { log("maxMem ignored unless forked: " + maxMem, Project.MSG_WARN); } IMessageHolder holder = messageHolder; int numPreviousErrors; if (null == holder) { MessageHandler mhandler = new MessageHandler(true); final IMessageHandler delegate; delegate = new AntMessageHandler(this.logger, this.verbose, false); mhandler.setInterceptor(delegate); holder = mhandler; numPreviousErrors = 0; } else { numPreviousErrors = holder.numMessages(IMessage.ERROR, true); } AjdtCommandForAnt command = new AjdtCommandForAnt(); { Main newmain = new Main(); newmain.setCommand(command); newmain.setHolder(holder); newmain.setCompletionRunner(new Runnable() { public void run() { doCompletionTasks(); } }); if (null != main) { MessageUtil.fail(holder, "still running prior main"); return false; } main = newmain; } main.runMain(args, false); if (failonerror) { int errs = holder.numMessages(IMessage.ERROR, false); errs -= numPreviousErrors; if (0 < errs) { String m = errs + " errors"; MessageUtil.print(System.err, holder, "", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ERROR, true); throw new BuildException(m); } } // Throw BuildException if there are any fail or abort // messages. // The BuildException message text has a list of class names // for the exceptions found in the messages, or the // number of fail/abort messages found if there were // 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())); String thrownMessage = t.getMessage(); if (!LangUtil.isEmpty(thrownMessage)) { sb.append(" \"" + thrownMessage + "\""); } } sb.append("\"" + message + "\""); prefix = ", "; } if (0 < sb.length()) { sb.append(" (" + numThrown + " exceptions)"); throw new BuildException(sb.toString()); } } } return command.isFailed(); }