Don't cancel autobuilds, wait for them, log errors.

Change-Id: Ic39f396e73fb810e8379d41937f50f52e1da90ea
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
diff --git a/org.eclipse.tea.core.ui/src/org/eclipse/tea/core/ui/internal/listeners/AutoBuildDeactivator.java b/org.eclipse.tea.core.ui/src/org/eclipse/tea/core/ui/internal/listeners/AutoBuildDeactivator.java
index afac047..bb7a44b 100644
--- a/org.eclipse.tea.core.ui/src/org/eclipse/tea/core/ui/internal/listeners/AutoBuildDeactivator.java
+++ b/org.eclipse.tea.core.ui/src/org/eclipse/tea/core/ui/internal/listeners/AutoBuildDeactivator.java
@@ -65,7 +65,7 @@
 	public synchronized void begin(TaskingLog log) throws CoreException {
 		if (nestCount.getAndIncrement() == 0) {
 			log.debug("Disabling automatic build...");
-			autoBuildOriginalState = setAutoBuild(log, false);
+			autoBuildOriginalState = setAutoBuild(log, false, false);
 		}
 	}
 
@@ -87,10 +87,10 @@
 						"The Eclipse automatic build is disabled. Since the build was successful,"
 								+ " enabling the automatic build is recommended."
 								+ " Should the automatic build be enabled now?");
-				setAutoBuild(log, autoBuild);
+				setAutoBuild(log, autoBuild, true); // suppress in headed mode
 			});
 		} else {
-			setAutoBuild(log, autoBuildOriginalState);
+			setAutoBuild(log, autoBuildOriginalState, !TaskingInjectionHelper.isHeadless(context.getContext()));
 		}
 	}
 
@@ -144,7 +144,7 @@
 		}
 	}
 
-	private boolean setAutoBuild(TaskingLog log, boolean autoBuild) {
+	private boolean setAutoBuild(TaskingLog log, boolean autoBuild, boolean suppressBuild) {
 		boolean originalState = false;
 		synchronized (suppressedProjects) {
 			try {
@@ -156,7 +156,7 @@
 
 				// we have 100ms worst case to react (scheduling delay of auto
 				// build).
-				if (!suppressedProjects.isEmpty()) {
+				if (!suppressedProjects.isEmpty() && suppressBuild) {
 					suppressBuild(suppressedProjects);
 				}
 			} catch (Exception e) {
diff --git a/org.eclipse.tea.core/src/org/eclipse/tea/core/internal/listeners/WorkspaceSaver.java b/org.eclipse.tea.core/src/org/eclipse/tea/core/internal/listeners/WorkspaceSaver.java
index 02754b4..77c4dd8 100644
--- a/org.eclipse.tea.core/src/org/eclipse/tea/core/internal/listeners/WorkspaceSaver.java
+++ b/org.eclipse.tea.core/src/org/eclipse/tea/core/internal/listeners/WorkspaceSaver.java
@@ -12,12 +12,14 @@
 
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.tea.core.services.TaskingHeadlessLifeCycle;
+import org.eclipse.tea.core.services.TaskingHeadlessLifeCycle.HeadlessPrority;
 import org.eclipse.tea.core.services.TaskingLog;
 import org.osgi.service.component.annotations.Component;
 
 /**
  * Makes sure the workspace is saved when execution of all tasks is done.
  */
+@HeadlessPrority(200)
 @Component
 public class WorkspaceSaver implements TaskingHeadlessLifeCycle {
 
diff --git a/org.eclipse.tea.library.build/src/org/eclipse/tea/library/build/tasks/jar/TaskRunJarExport.java b/org.eclipse.tea.library.build/src/org/eclipse/tea/library/build/tasks/jar/TaskRunJarExport.java
index 8cc0c3b..4f34fc1 100644
--- a/org.eclipse.tea.library.build/src/org/eclipse/tea/library/build/tasks/jar/TaskRunJarExport.java
+++ b/org.eclipse.tea.library.build/src/org/eclipse/tea/library/build/tasks/jar/TaskRunJarExport.java
@@ -147,6 +147,11 @@
 
 						IStatus status = TeaBuildUtil.getStatus(new TeaBuildPluginElement(pb));
 						if (status.getSeverity() > IStatus.WARNING) {
+							for (IStatus s : status.getChildren()) {
+								if (s.getSeverity() > IStatus.WARNING) {
+									log.debug(s.getMessage());
+								}
+							}
 							throw new RuntimeException(pb.getPluginName() + " has errors");
 						}