roll back due to pde build breakage
diff --git a/ui/org.eclipse.pde.ui/.classpath b/ui/org.eclipse.pde.ui/.classpath
index 849c21f..7f56ef6 100644
--- a/ui/org.eclipse.pde.ui/.classpath
+++ b/ui/org.eclipse.pde.ui/.classpath
@@ -19,7 +19,6 @@
     <classpathentry kind="src" path="/org.eclipse.ui"/>

     <classpathentry kind="src" path="/org.eclipse.update.core"/>

     <classpathentry kind="src" path="/org.eclipse.update.ui.forms"/>

-    <classpathentry kind="src" path="/org.eclipse.ant.ui"/>

     <classpathentry kind="src" path="/org.eclipse.core.boot"/>

     <classpathentry kind="src" path="/org.eclipse.core.runtime"/>

     <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

diff --git a/ui/org.eclipse.pde.ui/.project b/ui/org.eclipse.pde.ui/.project
index e307ac5..471c269 100644
--- a/ui/org.eclipse.pde.ui/.project
+++ b/ui/org.eclipse.pde.ui/.project
@@ -5,7 +5,6 @@
 	<projects>

 		<project>org.apache.xerces</project>

 		<project>org.eclipse.ant.core</project>

-		<project>org.eclipse.ant.ui</project>

 		<project>org.eclipse.core.boot</project>

 		<project>org.eclipse.core.resources</project>

 		<project>org.eclipse.core.runtime</project>

diff --git a/ui/org.eclipse.pde.ui/plugin.xml b/ui/org.eclipse.pde.ui/plugin.xml
index 1e6d43d..cd17afb 100644
--- a/ui/org.eclipse.pde.ui/plugin.xml
+++ b/ui/org.eclipse.pde.ui/plugin.xml
@@ -30,7 +30,6 @@
       <import plugin="org.eclipse.ui"/>

       <import plugin="org.eclipse.update.core"/>

       <import plugin="org.eclipse.update.ui.forms"/>

-      <import plugin="org.eclipse.ant.ui"/>

    </requires>

 

 

diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/FeatureBuildOperation.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/FeatureBuildOperation.java
index 10d2483..bf120b0 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/FeatureBuildOperation.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/site/FeatureBuildOperation.java
@@ -19,7 +19,7 @@
 import org.eclipse.core.resources.*;
 import org.eclipse.core.runtime.*;
 import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
+import org.eclipse.pde.internal.build.FeatureBuildScriptGenerator;
 import org.eclipse.pde.internal.core.*;
 import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
 import org.eclipse.pde.internal.core.isite.*;
@@ -233,14 +233,13 @@
 			new FeatureBuildScriptGenerator();
 		IFile featureFile = (IFile) featureModel.getUnderlyingResource();
 		String scriptName = "build.xml";
-		//generator.setBuildScriptName(scriptName);
+		generator.setBuildScriptName(scriptName);
 		generator.setFeatureRootLocation(
 			featureFile.getParent().getLocation().toOSString());
-		generator.setGenerateIncludedFeatures(true);
-		generator.setAnalyseChildren(true);
+		generator.setGenerateChildrenScript(true);
 		IPath platform =
 			Platform.getLocation().append(featureFile.getProject().getName());
-		generator.setWorkingDirectory(platform.toOSString());
+		generator.setInstallLocation(platform.toOSString());
 		generator.setDevEntries(new String[] { "bin" });
 		URL[] pluginPath = TargetPlatform.createPluginPath();
 		generator.setPluginPath(pluginPath);
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BaseBuildAction.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BaseBuildAction.java
deleted file mode 100644
index dfcc4e3..0000000
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BaseBuildAction.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package org.eclipse.pde.internal.ui.feature;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.ant.ui.internal.launchConfigurations.AntLaunchShortcut;
-import org.eclipse.ant.ui.internal.model.IAntUIConstants;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.pde.internal.core.TargetPlatform;
-import org.eclipse.pde.internal.ui.PDEPlugin;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-public abstract class BaseBuildAction implements IObjectActionDelegate {
-	
-	protected IFile file;
-
-	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
-
-	}
-
-	public void run(IAction action) {
-		if (!file.exists())
-			return;
-
-		IRunnableWithProgress op = new IRunnableWithProgress() {
-			public void run(IProgressMonitor monitor) {
-				IWorkspaceRunnable wop = new IWorkspaceRunnable() {
-					public void run(IProgressMonitor monitor) throws CoreException {
-						try {
-							doBuild(monitor);
-						} catch (InvocationTargetException e) {
-							PDEPlugin.logException(e);
-						}
-					}
-				};
-				try {
-					PDEPlugin.getWorkspace().run(wop, monitor);
-				} catch (CoreException e) {
-					PDEPlugin.logException(e);
-				}
-			}
-		};
-		ProgressMonitorDialog pmd =
-			new ProgressMonitorDialog(PDEPlugin.getActiveWorkbenchShell());
-		try {
-			pmd.run(false, false, op);
-		} catch (InterruptedException e) {
-		} catch (InvocationTargetException e) {
-			PDEPlugin.logException(e);
-		}
-
-	}
-
-	public void selectionChanged(IAction action, ISelection selection) {
-		if (selection instanceof IStructuredSelection) {
-			Object obj = ((IStructuredSelection) selection).getFirstElement();
-			if (obj != null && obj instanceof IFile) {
-				this.file = (IFile) obj;
-			}
-		}
-
-	}
-	
-	private void doBuild(IProgressMonitor monitor)
-		throws CoreException, InvocationTargetException {
-			monitor.beginTask(PDEPlugin.getResourceString("BuildAction.Validate"), 4);
-			if (!ensureValid(monitor)) {
-				monitor.done();
-				return;
-			}
-			monitor.worked(1);
-			monitor.setTaskName(PDEPlugin.getResourceString("BuildAction.Generate"));
-			makeScripts(monitor);
-			monitor.worked(1);
-			monitor.setTaskName(PDEPlugin.getResourceString("BuildAction.Update"));
-			refreshLocal(monitor);
-			monitor.worked(1);
-			setDefaultValues();
-			monitor.worked(1);
-			
-		}
-		
-	protected abstract void makeScripts(IProgressMonitor monitor)
-		throws InvocationTargetException, CoreException;
-
-	private boolean ensureValid(IProgressMonitor monitor) throws CoreException {
-		// Force the build if autobuild is off
-		IProject project = file.getProject();
-		if (!project.getWorkspace().isAutoBuilding()) {
-			project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
-		}
-
-		if (hasErrors(file)) {
-			// There are errors against this file - abort
-			MessageDialog.openError(
-				null,
-				PDEPlugin.getResourceString("BuildAction.ErrorDialog.Title"),
-				PDEPlugin.getResourceString("BuildAction.ErrorDialog.Message"));
-			return false;
-		}
-		return true;
-	}
-	
-	private boolean hasErrors(IFile file) throws CoreException {
-		IMarker[] markers = file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
-		for (int i = 0; i < markers.length; i++) {
-			Object att = markers[i].getAttribute(IMarker.SEVERITY);
-			if (att != null && att instanceof Integer) {
-				if (((Integer) att).intValue() == IMarker.SEVERITY_ERROR)
-					return true;
-			}
-		}
-		return false;
-	}
-	
-	protected void refreshLocal(IProgressMonitor monitor) throws CoreException {
-		file.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
-	}
-	
-	private void setDefaultValues() {
-		IProject project = file.getProject();
-		IFile generatedFile = (IFile) project.findMember("build.xml");
-		if (generatedFile == null)
-			return;
-
-		try {
-			List configs =
-				AntLaunchShortcut.findExistingLaunchConfigurations(generatedFile);
-			ILaunchConfigurationWorkingCopy launchCopy;
-			if (configs.size() == 0) {
-				ILaunchConfiguration config =
-					AntLaunchShortcut.createDefaultLaunchConfiguration(generatedFile);
-				launchCopy = config.getWorkingCopy();
-			} else {
-				launchCopy = ((ILaunchConfiguration) configs.get(0)).getWorkingCopy();
-			}
-			if (launchCopy == null)
-				return;
-
-			Map properties = new HashMap();
-			properties =
-				launchCopy.getAttribute(IAntUIConstants.ATTR_ANT_PROPERTIES, properties);
-			properties.put("ws", TargetPlatform.getWS());
-			properties.put("os", TargetPlatform.getOS());
-			properties.put("arch", TargetPlatform.getOSArch());
-			launchCopy.setAttribute(IAntUIConstants.ATTR_ANT_PROPERTIES, properties);
-			launchCopy.doSave();
-		} catch (CoreException e) {
-		}
-	}
-
-}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildFeatureAction.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildFeatureAction.java
index 0fd62d3..62c0a1a 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildFeatureAction.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildFeatureAction.java
@@ -11,55 +11,195 @@
 package org.eclipse.pde.internal.ui.feature;
 
 import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
 
 import org.eclipse.core.resources.*;
 import org.eclipse.core.runtime.*;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.*;
 import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
-import org.eclipse.pde.internal.core.PDECore;
+import org.eclipse.pde.internal.build.FeatureBuildScriptGenerator;
 import org.eclipse.pde.internal.core.TargetPlatform;
+import org.eclipse.pde.internal.core.feature.WorkspaceFeatureModel;
 import org.eclipse.pde.internal.core.ifeature.*;
 import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.util.SWTUtil;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.*;
 
-public class BuildFeatureAction extends BaseBuildAction {
+public class BuildFeatureAction implements IObjectActionDelegate {
+	public static final String KEY_ERRORS_TITLE = "GenerateFeatureJars.errorsTitle";
+	public static final String KEY_ERRORS_MESSAGE =
+		"GenerateFeatureJars.errorsMessage";
+	public static final String KEY_VERIFYING = "GenerateFeatureJars.verifying";
+	public static final String KEY_GENERATING = "GenerateFeatureJars.generating";
+	public static final String KEY_UPDATING = "GenerateFeatureJars.updating";
+	private IFile featureFile;
+
+	public IFile getFeatureFile() {
+		return featureFile;
+	}
+	public void run(IAction action) {
+		if (featureFile == null)
+			return;
+		if (featureFile.exists() == false)
+			return;
+
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor) {
+				IWorkspaceRunnable wop = new IWorkspaceRunnable() {
+					public void run(IProgressMonitor monitor) throws CoreException {
+						try {
+							doBuildFeature(monitor);
+						} catch (InvocationTargetException e) {
+							syncLogException(e);
+						}
+					}
+				};
+				try {
+					PDEPlugin.getWorkspace().run(wop, monitor);
+				} catch (CoreException e) {
+					syncLogException(e);
+				}
+			}
+		};
+		ProgressMonitorDialog pmd =
+			new ProgressMonitorDialog(PDEPlugin.getActiveWorkbenchShell());
+		try {
+			pmd.run(false, false, op);
+//			if (errors) return;
+//			final Display display = PDEPlugin.getActiveWorkbenchShell().getDisplay();
+//			display.asyncExec(new Runnable() {
+//				public void run() {
+//					BusyIndicator.showWhile(display, new Runnable() {
+//						public void run() {
+//							runAnt();
+//						}
+//					});
+//				}
+//			});
+		} catch (InterruptedException e) {
+		} catch (InvocationTargetException e) {
+			PDEPlugin.logException(e);
+		}
+	}
 	
-	private IFeatureModel model;
+	private void syncLogException(final Throwable e) {
+		final Display display = SWTUtil.getStandardDisplay();
+		if (display!=null) {
+			display.syncExec(new Runnable() {
+				public void run() {
+					PDEPlugin.logException(e);
+				}
+			});
+		}
+		else
+			PDEPlugin.log(e);
+	}
 
-	protected void makeScripts(IProgressMonitor monitor)
+	public void selectionChanged(IAction action, ISelection selection) {
+		IFile file = null;
+
+		if (selection instanceof IStructuredSelection) {
+			Object obj = ((IStructuredSelection) selection).getFirstElement();
+			if (obj != null && obj instanceof IFile) {
+				file = (IFile) obj;
+				String name = file.getName().toLowerCase();
+				if (!name.equals("feature.xml")) {
+					file = null;
+				}
+			}
+		}
+		this.featureFile = file;
+	}
+
+	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+	}
+	public void setFeatureFile(IFile featureFile) {
+		this.featureFile = featureFile;
+	}
+
+	private void doBuildFeature(IProgressMonitor monitor)
+		throws InvocationTargetException, CoreException {
+		monitor.beginTask(PDEPlugin.getResourceString(KEY_VERIFYING), 3);
+		if (ensureValid(monitor) == false) {
+			return;
+		}
+		monitor.worked(1);
+		WorkspaceFeatureModel model = new WorkspaceFeatureModel(featureFile);
+		model.load();
+		monitor.setTaskName(PDEPlugin.getResourceString(KEY_GENERATING));
+		makeScripts(model, monitor);
+		monitor.worked(1);
+		monitor.setTaskName(PDEPlugin.getResourceString(KEY_UPDATING));
+		refreshLocal(model, monitor);
+		monitor.worked(1);
+		monitor.done();
+	}
+
+	private boolean ensureValid(IProgressMonitor monitor) throws CoreException {
+		// Force the build if autobuild is off
+		IProject project = featureFile.getProject();
+		if (!project.getWorkspace().isAutoBuilding()) {
+			project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+		}
+		// Check if there are errors against feature file
+		if (hasErrors(featureFile)) {
+			// There are errors against this file - abort
+			String message;
+			message = PDEPlugin.getResourceString(KEY_ERRORS_MESSAGE);
+			MessageDialog.openError(
+				null,
+				PDEPlugin.getResourceString(KEY_ERRORS_TITLE),
+				message);
+			return false;
+		}
+		return true;
+	}
+	
+	private boolean hasErrors(IFile file) throws CoreException {
+		// Check if there are errors against feature file
+		IMarker[] markers =file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
+		for (int i=0; i<markers.length; i++) {
+			IMarker marker = markers[i];
+			Object att = marker.getAttribute(IMarker.SEVERITY);
+			if (att!=null && att instanceof Integer) {
+				Integer severity = (Integer)att;
+				if (severity.intValue()==IMarker.SEVERITY_ERROR) return true;
+			}
+		}
+		return false;
+	}
+
+	private void makeScripts(IFeatureModel model, IProgressMonitor monitor)
 		throws InvocationTargetException, CoreException {
 
 		FeatureBuildScriptGenerator generator = new FeatureBuildScriptGenerator();
-		
-		String location = file.getProject().getLocation().toOSString();
-		generator.setWorkingDirectory(location);
-		generator.setFeatureRootLocation(location);
+
+		String scriptName = "build.xml";
+		generator.setBuildScriptName(scriptName);
+		generator.setFeatureRootLocation(
+			getFeatureFile().getParent().getLocation().toOSString());
+
+		IPath platform =
+			Platform.getLocation().append(featureFile.getProject().getName());
+		generator.setInstallLocation(platform.toOSString());
 		generator.setDevEntries(new String[] { "bin" }); // FIXME: look at bug #5747
-		
-		ArrayList paths = new ArrayList();
-		IFeatureModel[] models = PDECore.getDefault().getWorkspaceModelManager().getWorkspaceFeatureModels();
-		for (int i = 0; i < models.length; i++) {
-			try {
-				paths.add(new URL("file:" + models[i].getInstallLocation() + Path.SEPARATOR + "feature.xml"));
-			} catch (MalformedURLException e1) {
-			}
-			if (models[i].getUnderlyingResource().equals(file))
-				model = models[i];
-		}
-		
-		URL[] plugins = TargetPlatform.createPluginPath();
-		URL[] features = (URL[]) paths.toArray(new URL[paths.size()]);
-		URL[] all = new URL[plugins.length + paths.size()];
-		System.arraycopy(plugins, 0, all, 0, plugins.length);
-		System.arraycopy(features, 0, all, plugins.length, features.length);
-		
-		generator.setPluginPath(all);
+
+		// RTP: set this to false when you do not want to generate scripts for this
+		// feature's children. The default is true.
+		//	generator.setGenerateChildrenScript(children);
+
+		URL[] pluginPath = TargetPlatform.createPluginPath();
+		generator.setPluginPath(pluginPath);
 
 		try {
+			monitor.subTask(PDEPlugin.getResourceString(KEY_GENERATING));
 			generator.setFeature(model.getFeature().getId());
 			generator.generate();
+			monitor.subTask(PDEPlugin.getResourceString(KEY_UPDATING));
 		} catch (Exception e) {
 			PDEPlugin.logException(e);
 		}
@@ -69,7 +209,8 @@
 		throws CoreException {
 		IFeaturePlugin[] references = feature.getPlugins();
 		for (int i = 0; i < references.length; i++) {
-			IPluginModelBase refmodel = feature.getReferencedModel(references[i]);
+			IFeaturePlugin ref = references[i];
+			IPluginModelBase refmodel = feature.getReferencedModel(ref);
 			if (refmodel != null) {
 				refmodel.getUnderlyingResource().getProject().refreshLocal(
 					IResource.DEPTH_INFINITE,
@@ -77,12 +218,23 @@
 			}
 		}
 	}
-	
-	protected void refreshLocal(IProgressMonitor monitor)
+	private void refreshLocal(IFeatureModel model, IProgressMonitor monitor)
 		throws CoreException {
-		super.refreshLocal(monitor);
-		refreshLocal(model.getFeature(), monitor);
+		// refresh feature
+		featureFile.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+		// refresh references
+		IFeature feature = model.getFeature();
+		refreshLocal(feature, monitor);
 	}
-	
 
+//	private void runAnt() {
+//		String scriptName = MainPreferencePage.getBuildScriptName();
+//		IFile file = featureFile.getProject().getFile(scriptName);
+//		if (!file.exists()) {
+//			// should probably warn the user
+//			return;
+//		}
+//		AntLaunchShortcut launch = new AntLaunchShortcut();
+//		launch.launch(new StructuredSelection(file), ILaunchManager.RUN_MODE);
+//	}
 }
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildPluginAction.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildPluginAction.java
index fa47268..776e0ca 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildPluginAction.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/feature/BuildPluginAction.java
@@ -11,40 +11,221 @@
 package org.eclipse.pde.internal.ui.feature;
 
 import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
 
 import org.eclipse.core.resources.*;
 import org.eclipse.core.runtime.*;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.*;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.*;
 import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.build.builder.FragmentBuildScriptGenerator;
-import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator;
-import org.eclipse.pde.internal.build.builder.PluginBuildScriptGenerator;
+import org.eclipse.pde.internal.build.*;
 import org.eclipse.pde.internal.core.*;
+import org.eclipse.pde.internal.ui.PDEPlugin;
+import org.eclipse.pde.internal.ui.util.SWTUtil;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.*;
 
-public class BuildPluginAction extends BaseBuildAction {
+public class BuildPluginAction implements IObjectActionDelegate {
+	public static final String KEY_ERRORS_TITLE = "GeneratePluginJars.errorsTitle";
+	public static final String KEY_ERRORS_MESSAGE =
+		"GeneratePluginJars.errorsMessage";
+	public static final String KEY_ERRORS_FMESSAGE =
+		"GeneratePluginJars.errorsFMessage";
+	public static final String KEY_VERIFYING = "GeneratePluginJars.verifying";
+	public static final String KEY_GENERATING = "GeneratePluginJars.generating";
+	public static final String KEY_UPDATING = "GeneratePluginJars.updating";
+	private IFile pluginBaseFile;
+	private boolean fragment;
 
-	protected void makeScripts(IProgressMonitor monitor)
+	public IFile getPluginBaseFile() {
+		return pluginBaseFile;
+	}
+	public void run(IAction action) {
+		if (pluginBaseFile == null)
+			return;
+		if (pluginBaseFile.exists() == false)
+			return;
+
+		IRunnableWithProgress op = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor) {
+				IWorkspaceRunnable wop = new IWorkspaceRunnable() {
+					public void run(IProgressMonitor monitor) throws CoreException {
+						try {
+							doBuildPlugin(monitor);
+						} catch (InvocationTargetException e) {
+							syncLogException(e);
+						}
+					}
+				};
+				try {
+					PDEPlugin.getWorkspace().run(wop, monitor);
+				} catch (CoreException e) {
+					syncLogException(e);
+				}
+			}
+		};
+		ProgressMonitorDialog pmd =
+			new ProgressMonitorDialog(PDEPlugin.getActiveWorkbenchShell());
+		try {
+			pmd.run(false, false, op);
+			/*
+			if (errors) return;
+			final Display display = PDEPlugin.getActiveWorkbenchShell().getDisplay();
+			display.asyncExec(new Runnable() {
+				public void run() {
+					BusyIndicator.showWhile(display, new Runnable() {
+						public void run() {
+							runAnt();
+						}
+					});
+				}
+			});
+			*/
+		} catch (InterruptedException e) {
+		} catch (InvocationTargetException e) {
+			PDEPlugin.logException(e);
+		}
+	}
+	
+	private void syncLogException(final Throwable e) {
+		//final Display display = PDEPlugin.getActiveWorkbenchShell().getDisplay();
+		final Display display = SWTUtil.getStandardDisplay();
+		if (display!=null) {
+			display.syncExec(new Runnable() {
+				public void run() {
+					PDEPlugin.logException(e);
+				}
+			});
+		}
+		else 
+			PDEPlugin.log(e);
+	}
+	
+	public void selectionChanged(IAction action, ISelection selection) {
+		IFile file = null;
+
+		if (selection instanceof IStructuredSelection) {
+			Object obj = ((IStructuredSelection) selection).getFirstElement();
+			if (obj != null && obj instanceof IFile) {
+				file = (IFile) obj;
+				String name = file.getName().toLowerCase();
+				if (name.equals("plugin.xml")) {
+					fragment = false;
+				} else if (name.equals("fragment.xml")) {
+					fragment = true;
+				} else
+					file = null;
+			}
+		}
+		this.pluginBaseFile = file;
+	}
+
+	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+	}
+	public void setPluginBaseFile(IFile pluginBaseFile) {
+		this.pluginBaseFile = pluginBaseFile;
+	}
+
+	private void doBuildPlugin(IProgressMonitor monitor)
+		throws InvocationTargetException, CoreException {
+		monitor.beginTask(PDEPlugin.getResourceString(KEY_VERIFYING), 3);
+		if (ensureValid(monitor) == false) {
+			return;
+		}
+		monitor.worked(1);
+		monitor.setTaskName(PDEPlugin.getResourceString(KEY_GENERATING));
+		makeScripts(monitor);
+		monitor.worked(1);
+		monitor.setTaskName(PDEPlugin.getResourceString(KEY_UPDATING));
+		refreshLocal(monitor);
+		monitor.worked(1);
+		monitor.done();
+	}
+
+	private boolean ensureValid(IProgressMonitor monitor) throws CoreException {
+		// Force the build if autobuild is off
+		IProject project = pluginBaseFile.getProject();
+		if (!project.getWorkspace().isAutoBuilding()) {
+			project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+		}
+
+		if (hasErrors(pluginBaseFile)) {
+			// There are errors against this file - abort
+			String message;
+			if (fragment)
+				message = PDEPlugin.getResourceString(KEY_ERRORS_FMESSAGE);
+			else
+				message = PDEPlugin.getResourceString(KEY_ERRORS_MESSAGE);
+			MessageDialog.openError(
+				null,
+				PDEPlugin.getResourceString(KEY_ERRORS_TITLE),
+				message);
+			return false;
+		}
+		return true;
+	}
+	
+	private boolean hasErrors(IFile file) throws CoreException {
+		// Check if there are errors against feature file
+		IMarker[] markers =file.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);
+		for (int i=0; i<markers.length; i++) {
+			IMarker marker = markers[i];
+			Object att = marker.getAttribute(IMarker.SEVERITY);
+			if (att!=null && att instanceof Integer) {
+				Integer severity = (Integer)att;
+				if (severity.intValue()==IMarker.SEVERITY_ERROR) return true;
+			}
+		}
+		return false;
+	}
+
+	private void makeScripts(IProgressMonitor monitor)
 		throws InvocationTargetException, CoreException {
 
 		ModelBuildScriptGenerator generator;
-		
-		if (file.getName().toLowerCase().equals("fragment.xml"))
+		if (fragment)
 			generator = new FragmentBuildScriptGenerator();
 		else
 			generator = new PluginBuildScriptGenerator();
 		
-		IProject project = file.getProject();
-		generator.setWorkingDirectory(project.getLocation().toOSString());
+		String scriptName = "build.xml";
+		generator.setBuildScriptName(scriptName);
+
+		IProject project = pluginBaseFile.getProject();
+		IPluginModelBase model = (IPluginModelBase)
+			PDECore.getDefault().getWorkspaceModelManager().getWorkspaceModel(project);
+		IPath platform =
+			Platform.getLocation().append(
+				model.getUnderlyingResource().getProject().getName());
+		generator.setInstallLocation(platform.toOSString());
 		generator.setDevEntries(new String[] {"bin"}); // FIXME: look at bug #5747
-		generator.setPluginPath(TargetPlatform.createPluginPath());
+
+		URL [] pluginPath = TargetPlatform.createPluginPath();
+		generator.setPluginPath(pluginPath);
 
 		try {
-			WorkspaceModelManager manager = PDECore.getDefault().getWorkspaceModelManager();
-			IPluginModelBase model = (IPluginModelBase) manager.getWorkspaceModel(project);
 			generator.setModelId(model.getPluginBase().getId());
 			generator.generate();
-		} catch (CoreException e) {
+		} catch (Exception e) {
 			throw new InvocationTargetException(e);
 		}
 	}
 
+	private void refreshLocal(IProgressMonitor monitor) throws CoreException {
+		// refresh feature
+		pluginBaseFile.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+	}
+
+//	private void runAnt() {
+//		String scriptName = MainPreferencePage.getBuildScriptName();
+//		IFile file = pluginBaseFile.getProject().getFile(scriptName);
+//		if (!file.exists()) {
+//			// should probably warn the user
+//			return;
+//		}
+//		AntLaunchShortcut launch = new AntLaunchShortcut();
+//		launch.launch(new StructuredSelection(file), ILaunchManager.RUN_MODE);
+//	}
 }
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ExportFeatureBuildScriptGenerator.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ExportFeatureBuildScriptGenerator.java
index 88c3533..4795856 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ExportFeatureBuildScriptGenerator.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ExportFeatureBuildScriptGenerator.java
@@ -18,58 +18,60 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.model.PluginModel;
-
+import org.eclipse.pde.internal.build.FeatureBuildScriptGenerator;
 import org.eclipse.pde.internal.build.Policy;
 import org.eclipse.pde.internal.build.Utils;
 import org.eclipse.pde.internal.build.ant.AntScript;
-import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
 
 public class ExportFeatureBuildScriptGenerator extends FeatureBuildScriptGenerator {
 	protected void generateZipDistributionWholeTarget(AntScript script) {
+		int tab = 1;
 		script.println();
-		script.printTargetDeclaration(TARGET_ZIP_DISTRIBUTION, TARGET_INIT, null, null, Policy.bind("build.feature.zips",featureIdentifier)); //$NON-NLS-1$
-		script.printMkdirTask(getPropertyFormat(PROPERTY_FEATURE_TEMP_FOLDER));
+		script.printTargetDeclaration(tab++, TARGET_ZIP_DISTRIBUTION, TARGET_INIT, null, null, Policy.bind("build.feature.zips",featureID)); //$NON-NLS-1$
+		script.printMkdirTask(tab, FEATURE_TEMP_FOLDER);
 		Map params = new HashMap(1);
-		params.put(PROPERTY_FEATURE_BASE, getPropertyFormat(PROPERTY_FEATURE_TEMP_FOLDER));
+		params.put(PROPERTY_FEATURE_BASE, FEATURE_TEMP_FOLDER);
 		params.put(PROPERTY_INCLUDE_CHILDREN, "true"); //$NON-NLS-1$
-		script.printAntCallTask(TARGET_GATHER_BIN_PARTS, null, params);
-		script.printTargetEnd();
+		script.printAntCallTask(tab, TARGET_GATHER_BIN_PARTS, null, params);
+		script.printTargetEnd(--tab);
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.pde.internal.build.FeatureBuildScriptGenerator#generateZipSourcesTarget(org.eclipse.pde.internal.build.ant.AntScript)
 	 */
 	protected void generateZipSourcesTarget(AntScript script) {
+			int tab = 1;
 			script.println();
-			script.printTargetDeclaration(TARGET_ZIP_SOURCES, TARGET_INIT, null, null, null);
+			script.printTargetDeclaration(tab++, TARGET_ZIP_SOURCES, TARGET_INIT, null, null, null);
 			Map params = new HashMap(1);
 			params.put(PROPERTY_TARGET, TARGET_GATHER_SOURCES);
-			params.put(PROPERTY_DESTINATION_TEMP_FOLDER, getPropertyFormat(PROPERTY_FEATURE_TEMP_FOLDER) + "/" + "plugins"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-			script.printAntCallTask(TARGET_ALL_CHILDREN, null, params);
-			script.printTargetEnd();
+			params.put(PROPERTY_DESTINATION_TEMP_FOLDER, FEATURE_TEMP_FOLDER + "/" + "plugins"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+			script.printAntCallTask(tab, TARGET_ALL_CHILDREN, null, params);
+			script.printTargetEnd(--tab);
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.pde.internal.build.FeatureBuildScriptGenerator#generateAllPluginsTarget(org.eclipse.pde.internal.build.ant.AntScript)
 	 */
 	protected void generateAllPluginsTarget(AntScript script) throws CoreException {
+		int tab = 1;
 		List plugins = computeElements(false);
 		List fragments = computeElements(true);
 	
 		String[] sortedPlugins = Utils.computePrerequisiteOrder((PluginModel[]) plugins.toArray(new PluginModel[plugins.size()]), (PluginModel[]) fragments.toArray(new PluginModel[fragments.size()]));
 		script.println();
-		script.printTargetDeclaration(TARGET_ALL_PLUGINS, TARGET_INIT, null, null, null);
+		script.printTargetDeclaration(tab++, TARGET_ALL_PLUGINS, TARGET_INIT, null, null, null);
 			for (int i = 0; i < sortedPlugins.length; i++) {
-				PluginModel plugin = getSite(false).getPluginRegistry().getPlugin(sortedPlugins[i]);
+				PluginModel plugin = getRegistry().getPlugin(sortedPlugins[i]);
 				if (plugin==null)
-					plugin = getSite(false).getPluginRegistry().getFragment(sortedPlugins[i]);
+					plugin = getRegistry().getFragment(sortedPlugins[i]);
 				
-				IPath location = Utils.makeRelative(new Path(getLocation(plugin)), new Path(featureRootLocation));
+				IPath location = Utils.makeRelative(new Path(getLocation(plugin)), new Path(getFeatureRootLocation()));
 				Map params = new HashMap(1);
-				params.put(PROPERTY_BUILD_RESULT_FOLDER, getPropertyFormat(PROPERTY_FEATURE_TEMP_FOLDER) + "/build_result/" + plugin.getPluginId());
-				script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, location.toString(), getPropertyFormat(PROPERTY_TARGET), null, null, params);
+				params.put(PROPERTY_BUILD_RESULT_FOLDER, FEATURE_TEMP_FOLDER + "/build_result/" + plugin.getPluginId());
+				script.printAntTask(tab, buildScriptName, location.toString(), getPropertyFormat(PROPERTY_TARGET), null, null, params);
 			}
-		script.printTargetEnd();
+		script.printTargetEnd(--tab);
 	}
 
 }
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
index 73d0785..ead5f38 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/FeatureExportWizard.java
@@ -21,7 +21,7 @@
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.pde.core.IModel;
 import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.build.builder.FeatureBuildScriptGenerator;
+import org.eclipse.pde.internal.build.FeatureBuildScriptGenerator;
 import org.eclipse.pde.internal.core.ModelEntry;
 import org.eclipse.pde.internal.core.PDECore;
 import org.eclipse.pde.internal.core.PluginModelManager;
@@ -150,10 +150,10 @@
 	private void makeScript(IFeatureModel model) throws CoreException {
 		FeatureBuildScriptGenerator generator = new ExportFeatureBuildScriptGenerator();
 
-		//generator.setBuildScriptName(MainPreferencePage.getBuildScriptName());
-		//generator.setScriptTargetLocation(model.getInstallLocation());
+		generator.setBuildScriptName("build.xml");
+		generator.setScriptTargetLocation(model.getInstallLocation());
 		generator.setFeatureRootLocation(model.getInstallLocation());
-		generator.setWorkingDirectory(model.getInstallLocation());
+		generator.setInstallLocation(model.getInstallLocation());
 		
 		IProject project = model.getUnderlyingResource().getProject();
 		if (project.hasNature(JavaCore.NATURE_ID)) {
@@ -164,7 +164,7 @@
 			generator.setDevEntries(new String[] { "bin" });
 		}
 
-		generator.setAnalyseChildren(true);
+		generator.setGenerateChildrenScript(true);
 		generator.setPluginPath(TargetPlatform.createPluginPath());
 
 		generator.setFeature(model.getFeature().getId());
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
index 67c2081..ee5966b 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/PluginExportWizard.java
@@ -21,10 +21,9 @@
 import org.eclipse.pde.core.IModel;
 import org.eclipse.pde.core.plugin.IPluginBase;
 import org.eclipse.pde.core.plugin.IPluginModelBase;
-
-import org.eclipse.pde.internal.build.builder.FragmentBuildScriptGenerator;
-import org.eclipse.pde.internal.build.builder.ModelBuildScriptGenerator;
-import org.eclipse.pde.internal.build.builder.PluginBuildScriptGenerator;
+import org.eclipse.pde.internal.build.FragmentBuildScriptGenerator;
+import org.eclipse.pde.internal.build.ModelBuildScriptGenerator;
+import org.eclipse.pde.internal.build.PluginBuildScriptGenerator;
 import org.eclipse.pde.internal.core.TargetPlatform;
 import org.eclipse.pde.internal.ui.*;
 
@@ -54,9 +53,6 @@
 		map.put("temp.folder", buildTempLocation + Path.SEPARATOR + "eclipse" + Path.SEPARATOR + "plugins");
 		map.put("destination.temp.folder", buildTempLocation + Path.SEPARATOR + "eclipse" + Path.SEPARATOR + "plugins");
 		map.put("plugin.destination", destination);
-		map.put("os", TargetPlatform.getOS());
-		map.put("ws", TargetPlatform.getWS());
-		map.put("arch", TargetPlatform.getOSArch());
 		return map;
 	}
 	
@@ -114,9 +110,9 @@
 		else
 			generator = new PluginBuildScriptGenerator();
 
-		//generator.setBuildScriptName(MainPreferencePage.getBuildScriptName());
-		//generator.setScriptTargetLocation(model.getInstallLocation());
-		generator.setWorkingDirectory(model.getInstallLocation());
+		generator.setBuildScriptName("build.xml");
+		generator.setScriptTargetLocation(model.getInstallLocation());
+		generator.setInstallLocation(model.getInstallLocation());
 
 		IProject project = model.getUnderlyingResource().getProject();
 		if (project.hasNature(JavaCore.NATURE_ID)) {