protected boolean isCaptureOutputInConsoleView() {
   if (CommonUIPlugin.isFullyHeadless()) { // headless will be false always.
     return false;
   }
   // when debug, capture always.
   if (TalendDebugHandler.isEclipseDebug() || CommonsPlugin.isDebugMode()) {
     return true;
   }
   return captureOutputInConsoleView;
 }
  public void execute(IProgressMonitor monitor) throws Exception {

    /*
     * use the ExecutePomAction directly.
     */
    // ExecutePomAction exePomAction = new ExecutePomAction();
    // exePomAction.setInitializationData(null, null, MavenConstants.GOAL_COMPILE);
    // exePomAction.launch(new StructuredSelection(launcherPomFile), ILaunchManager.RUN_MODE);

    /*
     * use launch way
     */

    // try{

    ILaunchConfiguration launchConfiguration = createLaunchConfiguration();
    if (launchConfiguration == null) {
      throw new Exception("Can't create maven command launcher.");
    }
    // if (launchConfiguration instanceof ILaunchConfigurationWorkingCopy) {
    // ILaunchConfigurationWorkingCopy copiedConfig = (ILaunchConfigurationWorkingCopy)
    // launchConfiguration;
    // }
    TalendLauncherWaiter talendWaiter = new TalendLauncherWaiter(launchConfiguration);

    final ILaunch launch = buildAndLaunch(launchConfiguration, launcherMode, monitor);
    talendWaiter.waitFinish(launch);
    StringBuffer errors = new StringBuffer();
    for (IProcess process : launch.getProcesses()) {
      String log = process.getStreamsProxy().getOutputStreamMonitor().getContents();

      if (!isCaptureOutputInConsoleView()) {
        // specially for commandline. if studio, when debug model, will log it in console view, so
        // no need this.
        TalendDebugHandler.debug(
            "\n------------------ Talend Maven Launcher log START -----------------------\n");
        TalendDebugHandler.debug(log);
        TalendDebugHandler.debug(
            "\n------------------ Talend Maven Launcher log END -----------------------\n");
      }
      for (String line : log.split("\n")) { // $NON-NLS-1$
        if (line.startsWith("[ERROR]")) { // $NON-NLS-1$
          errors.append(line + "\n"); // $NON-NLS-1$
        }
      }
    }
    if (errors.length() > 0) {
      if (getGoals() != null
          && getGoals()
              .matches(
                  "(.*)\\b"
                      + TalendMavenConstants.GOAL_TEST
                      + "\\b(.*)")) { //$NON-NLS-1$//$NON-NLS-2$
        ExceptionHandler.process(new Exception(errors.toString()));
      } else {
        throw new Exception(errors.toString());
      }
    }

    // }finally{
    // if (launch != null) {
    // if remove, after execute launch, will remove the console also. so shouldn't remove it.
    // DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
    // }
    // }
  }