Merge branch 'IDEA-162949' of https://github.com/zdary/intellij-community
authorEugene Zhuravlev <jeka@intellij.com>
Wed, 2 Nov 2016 15:14:26 +0000 (16:14 +0100)
committerEugene Zhuravlev <jeka@intellij.com>
Wed, 2 Nov 2016 15:14:26 +0000 (16:14 +0100)
1  2 
java/java-runtime/src/com/intellij/rt/ant/execution/IdeaAntLogger2.java

index 49c81e5b4dc2c1fe5a46dd94e42d79aa0d3585af,c98f93333e07479d35830846ab9223d185beeb16..b9bee70ee37cbe87372eb5a1ca22e02e843eafd5
@@@ -24,7 -24,6 +24,7 @@@ import java.io.PrintStream
  import java.io.PrintWriter;
  import java.io.StringWriter;
  import java.lang.reflect.Field;
 +import java.util.Stack;
  
  public final class IdeaAntLogger2 extends DefaultLogger {
    static SegmentedOutputStream ourErr;
     */
    public static final String OUTPUT_PREFIX = "IDEA_ANT_INTEGRATION";
  
 +  private final ThreadLocal myCallingTasks = new ThreadLocal() {
 +    protected Object initialValue() {
 +      return new Stack();
 +    }
 +  };
 +
    private final Priority myMessagePriority = new MessagePriority();
    private final Priority myTargetPriority = new StatePriority(Project.MSG_INFO);
-   private final Priority myTaskPriority = new StatePriority(Project.MSG_INFO);
+   private final Priority myTaskPriority = new StatePriority(Project.MSG_VERBOSE);
    private final Priority myAlwaysSend = new Priority() {
      public void setPriority(int level) {}
  
    }
  
    public synchronized void taskStarted(BuildEvent event) {
 -    myTaskPriority.sendMessage(TASK, event.getPriority(), event.getTask().getTaskName());
 +    final String taskName = event.getTask().getTaskName();
 +    getTaskCallStack().push(taskName);
 +    myTaskPriority.sendMessage(TASK, event.getPriority(), taskName);
    }
  
    public synchronized void taskFinished(BuildEvent event) {
 -    sendException(event, true);
 -    myTaskPriority.sendMessage(TASK_END, event.getPriority(), event.getException());
 +    try {
 +      sendException(event, true);
 +      myTaskPriority.sendMessage(TASK_END, event.getPriority(), event.getException());
 +    }
 +    finally {
 +      getTaskCallStack().pop();
 +    }
    }
  
    public synchronized void messageLogged(BuildEvent event) {
    private boolean sendException(BuildEvent event, boolean isFailOnError) {
      Throwable exception = event.getException();
      if (exception != null) {
 -      if (isFailOnError) {
 +      final boolean insideTryTask = getTaskCallStack().contains("try");
 +      if (isFailOnError && !insideTryTask) {
          myAlwaysSend.sendMessage(EXCEPTION, event.getPriority(), exception);
          return true;
        }
 -      myMessagePriority.sendMessage(MESSAGE, Project.MSG_WARN, exception.getMessage());
 +      myMessagePriority.sendMessage(MESSAGE, insideTryTask? Project.MSG_VERBOSE : Project.MSG_WARN, exception.getMessage());
      }
      return false;
    }
      return packet;
    }
  
 +  private Stack getTaskCallStack() {
 +    return (Stack)myCallingTasks.get();
 +  }
 +
    private abstract class Priority {
      protected void peformSendMessage(char id, int priority, String text) {
        PacketWriter packet = createPacket(id, priority);