Index: plugin.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde.build/plugin.xml,v
retrieving revision 1.51
diff -u -r1.51 plugin.xml
--- plugin.xml	9 Mar 2005 21:08:14 -0000	1.51
+++ plugin.xml	14 Apr 2005 15:25:36 -0000
@@ -21,6 +21,11 @@
       </antTask>
       <antTask
             library="lib/pdebuild-ant.jar"
+            name="eclipse.sourceBuildScript"
+            class="org.eclipse.pde.internal.build.tasks.SourceBuildScriptGeneratorTask">
+      </antTask>
+      <antTask
+            library="lib/pdebuild-ant.jar"
             name="eclipse.buildManifest"
             class="org.eclipse.pde.internal.build.tasks.BuildManifestTask">
       </antTask>
Index: scripts/build.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde.build/scripts/build.xml,v
retrieving revision 1.13
diff -u -r1.13 build.xml
--- scripts/build.xml	21 Mar 2005 21:43:42 -0000	1.13
+++ scripts/build.xml	14 Apr 2005 15:25:36 -0000
@@ -9,6 +9,8 @@
 <property file="${buildProperties}"/>
 <property name="customTargets" location="${builderDirectory}/customTargets.xml"/>
 <property name="genericTargets" location="genericTargets.xml"/>
+<!-- temparily enabled for testing -->
+<property name="buildSourceDrop" value="true"/>
 
 <!-- ===================================================================== -->
 <!-- main entry point to setup, fetch, generate, build etc. Use -->
@@ -19,6 +21,7 @@
 <target name="main" description="the main build target">	
   	<antcall target="preBuild" /> 
  	<antcall target="fetch" />
+	<antcall target="buildSourceDrop" />
 	<antcall target="generate" /> 
 	<antcall target="process" /> 
 	<antcall target="assemble" />
@@ -65,6 +68,15 @@
 </target>
 
 <!-- ===================================================================== -->
+<!-- Make a buildable source zip -->
+<!-- ===================================================================== -->
+<target name="buildSourceDrop" if="buildSourceDrop" >
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="buildSourceDrop" />
+	</ant>
+</target>
+
+<!-- ===================================================================== -->
 <!-- Run the build scripts for each element identified in the customTargets -->
 <!-- ===================================================================== -->
 <target name="process">
Index: scripts/genericTargets.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde.build/scripts/genericTargets.xml,v
retrieving revision 1.9
diff -u -r1.9 genericTargets.xml
--- scripts/genericTargets.xml	31 Mar 2005 16:50:04 -0000	1.9
+++ scripts/genericTargets.xml	14 Apr 2005 15:25:36 -0000
@@ -8,6 +8,7 @@
 	recursiveGeneration
 	workingDirectory
 	configInfo
+	buildId
 -->
 
 <!-- ===================================================================== -->
@@ -64,6 +65,33 @@
 </target>
 
 <!-- ===================================================================== -->
+<!-- Make a build.xml for use in a buildable source zip -->
+<!-- ===================================================================== -->
+<target name="buildSourceDrop">
+
+	<eclipse.sourceBuildScript 
+		type="${type}"
+		id="${id}" 
+		buildDirectory="${buildDirectory}"
+		buildId="${buildId}"
+	/>
+	
+	<delete> 
+		<fileset dir="${buildDirectory}" includes="**/*.so,**/*.dll" />
+	</delete>
+	
+	<!-- TODO add logic for plugin only -->
+	<zip destfile="${buildDirectory}/${id}-${buildId}-sourceBuild.zip">
+    	<zipfileset dir="${buildDirectory}/features" prefix="eclipse/features"/>
+    	<zipfileset file="${buildDirectory}/featureVersions.properties" />
+    	<zipfileset dir="${buildDirectory}/plugins" prefix="eclipse/plugins"/>
+    	<zipfileset file="${buildDirectory}/pluginVersions.properties" />
+    	<zipfileset file="${buildDirectory}/${id}-build.xml" fullpath="build.xml" />
+    </zip>
+</target>
+
+
+<!-- ===================================================================== -->
 <!-- Run build.xml for a single element-->
 <!-- ===================================================================== -->
 <target name="processElement" description="Processing build scripts..." depends="init">
Index: src/org/eclipse/pde/internal/build/ant/AntScript.java
===================================================================
RCS file: /home/eclipse/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java,v
retrieving revision 1.36
diff -u -r1.36 AntScript.java
--- src/org/eclipse/pde/internal/build/ant/AntScript.java	11 Apr 2005 15:37:36 -0000	1.36
+++ src/org/eclipse/pde/internal/build/ant/AntScript.java	14 Apr 2005 15:25:36 -0000
@@ -83,6 +83,40 @@
 	}
 
 	/**
+	 * FIXME javadocs
+	 * Print an <code>antcall</code> task to the script. This calls Ant on the given 
+	 * target which is located within the same build file. 
+	 * 
+	 * @param target the target of the ant call
+	 * @param inheritAll <code>true</code> if the parameters should be pass to the
+	 * 	called target
+	 * @param params table of parameters for the call
+	 */
+	public void printAnt(String antfile, String dir, String target, String inheritAll, Map params) {
+		printTab();
+		output.print("<ant"); //$NON-NLS-1$
+		printAttribute("antfile", antfile, false); //$NON-NLS-1$
+		printAttribute("dir", dir, false); //$NON-NLS-1$
+		printAttribute("target", target, false); //$NON-NLS-1$
+		printAttribute("inheritAll", inheritAll, false); //$NON-NLS-1$
+		if (params == null)
+			output.println("/>"); //$NON-NLS-1$
+		else {
+			output.println(">"); //$NON-NLS-1$
+			indent++;
+			Set entries = params.entrySet();
+			for (Iterator iter = entries.iterator(); iter.hasNext();) {
+				Map.Entry entry = (Map.Entry) iter.next();
+				printParam((String) entry.getKey(), (String) entry.getValue());
+			}
+			indent--;
+			printTab();
+			output.println("</ant>"); //$NON-NLS-1$
+		}
+	}
+	
+	
+	/**
 	 * Print a <code>jar</code> Ant task to this script. This jars together a group of 
 	 * files into a single file.
 	 * 
@@ -397,6 +431,29 @@
 	}
 
 	/**
+	 FIXME java-doc
+	 */
+	public void printBuildScriptTask(String element, String buildDirectory, 
+			String configInfo, String baseLocation, boolean buildingOSGi) {
+		printTab();
+		indent++;
+		print("<eclipse.buildScript"); //$NON-NLS-1$
+		println(); printTab(); 
+		printAttribute("elements", element, true); //$NON-NLS-1$
+		println(); printTab(); 
+		printAttribute("buildDirectory", buildDirectory, true); //$NON-NLS-1$
+		println(); printTab(); 
+		printAttribute("configInfo", configInfo, true); //$NON-NLS-1$
+		println(); printTab(); 
+		printAttribute("baseLocation", baseLocation, true); //$NON-NLS-1$
+		println(); printTab(); 
+		printAttribute("buildingOSGi", buildingOSGi ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		println(); printTab(); 
+		indent--;
+		println("/>"); //$NON-NLS-1$
+	}
+	
+	/**
 	 * Print an <code>echo</code> task to the Ant script.
 	 * 
 	 * @param message the message to echo to the output
@@ -687,4 +744,12 @@
 		printAttribute("file", file, true); //$NON-NLS-1$
 		output.println("/>"); //$NON-NLS-1$
 	}
+
+	public void printTouch(String file) {
+		printTab();
+		output.print("<touch"); //$NON-NLS-1$
+		printAttribute("file", file, true); //$NON-NLS-1$
+		output.println("/>");  //$NON-NLS-1$
+	}
+	
 }
Index: src/org/eclipse/pde/internal/build/SourceBuildScriptGenerator.java
===================================================================
RCS file: src/org/eclipse/pde/internal/build/SourceBuildScriptGenerator.java
diff -N src/org/eclipse/pde/internal/build/SourceBuildScriptGenerator.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/pde/internal/build/SourceBuildScriptGenerator.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.build;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+
+public class SourceBuildScriptGenerator extends AbstractScriptGenerator {
+
+	private final static String PROPERTY_CONFIG = "config"; //$NON-NLS-1$
+	private final static String PROPERTY_BASE_LOCATION = "baseLocation"; //$NON-NLS-1$
+	private final static String PROPERTY_BUILD_TEMP_FOLDER = "buildTempFolder"; //$NON-NLS-1$
+	private final static String TARGET_BUILD = "build"; //$NON-NLS-1$
+	private final static String TARGET_GENERATE = "generate"; //$NON-NLS-1$
+	private final static String TARGET_ASSEMBLE = "assemble";  //$NON-NLS-1$
+	private final static String PREFIX = "eclipse"; //$NON-NLS-1$
+	
+	
+	
+	private String type;
+	private String id;
+	private String buildId;
+
+	/**
+	 * TODO: add javadocs
+	 * @throws CoreException
+	 */
+	public void generate() throws CoreException {
+		
+		openScript(workingDirectory, id + "-" + DEFAULT_BUILD_SCRIPT_FILENAME); //$NON-NLS-1$
+		script.println();
+		script.printComment("\"" + PROPERTY_BASE_LOCATION + "\" must be set by the caller of this script"); //$NON-NLS-1$ //$NON-NLS-2$
+		script.printProjectDeclaration("Build " + id, TARGET_MAIN, null); //$NON-NLS-1$
+		script.println();
+		
+		//TODO add logic to make ant fail if baseLocation isn't set (use condition task)
+		script.printTargetDeclaration(TARGET_INIT, null, null, null, null);
+		//TODO only allow builds on config triplets that the feature supports
+		script.printProperty(PROPERTY_CONFIG, getDefaultConfigInfos());
+		script.printProperty(PROPERTY_OS, "${osgi.os}"); //$NON-NLS-1$
+		script.printProperty(PROPERTY_WS, "${osgi.ws}"); //$NON-NLS-1$
+		script.printProperty(PROPERTY_ARCH, "${osgi.arch}"); //$NON-NLS-1$
+		script.printProperty(PROPERTY_BUILD_TEMP_FOLDER, getPropertyFormat(PROPERTY_BASEDIR) + "/results"); //$NON-NLS-1$
+		script.printProperty(PROPERTY_JAVAC_FAIL_ON_ERROR, TRUE);
+		script.printProperty(PROPERTY_JAVAC_VERBOSE, FALSE);
+		script.printTargetEnd();
+		script.println();
+	
+		script.printTargetDeclaration(TARGET_MAIN, TARGET_INIT, null, null, null);
+		script.printAntCallTask(TARGET_GENERATE, null, null);
+		script.printAntCallTask(TARGET_BUILD, null, null);
+		script.printAntCallTask(TARGET_ASSEMBLE, null, null);
+		script.printTargetEnd();
+		script.println();
+		
+		script.printTargetDeclaration(TARGET_GENERATE, null, null, null, null);
+		script.printBuildScriptTask(type + '@' + id, PREFIX, getPropertyFormat(PROPERTY_CONFIG), getPropertyFormat(PROPERTY_BASE_LOCATION), true); //$NON-NLS-1$
+		script.printTargetEnd();
+		script.println();
+		
+		script.printTargetDeclaration(TARGET_BUILD, null, null, null, null);
+		script.printAnt(DEFAULT_BUILD_SCRIPT_FILENAME, PREFIX + '/' + type + "s/" + id, TARGET_BUILD_JARS, null, null); //$NON-NLS-1$
+		script.printTargetEnd();
+		script.println();
+		
+		script.printTargetDeclaration(TARGET_ASSEMBLE, null, null, null, null);
+		Map map = new HashMap(1, 1F);
+		map.put("buildId", buildId); //$NON-NLS-1$
+		script.printAnt("assemble." + id + ".xml", PREFIX, null, null, map);  //$NON-NLS-1$ //$NON-NLS-2$
+		script.printTargetEnd();
+		script.println();
+		
+		script.printProjectEnd();
+		script.close();
+	}	
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public void setBuildId(String buildId) {
+		this.buildId = buildId;
+	}
+}
Index: src_ant/org/eclipse/pde/internal/build/tasks/SourceBuildScriptGeneratorTask.java
===================================================================
RCS file: src_ant/org/eclipse/pde/internal/build/tasks/SourceBuildScriptGeneratorTask.java
diff -N src_ant/org/eclipse/pde/internal/build/tasks/SourceBuildScriptGeneratorTask.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src_ant/org/eclipse/pde/internal/build/tasks/SourceBuildScriptGeneratorTask.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.pde.internal.build.tasks;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.pde.internal.build.SourceBuildScriptGenerator;
+
+/**
+ * FIXME fix all comments in this class
+ * Generate build scripts for the listed elements. This is the implementation of the "eclipse.buildScript" Ant task.
+ */
+public class SourceBuildScriptGeneratorTask extends Task {
+
+	/**
+	 * The application associated with this Ant task.
+	 */
+	protected SourceBuildScriptGenerator generator = new SourceBuildScriptGenerator();
+
+	public void execute() throws BuildException {
+		try {
+			run();
+		} catch (CoreException e) {
+			throw new BuildException(e);
+		}
+	}
+
+	public void run() throws CoreException {
+		generator.generate();
+	}
+
+	/**
+	 * Set the source elements for the script to be the given value.
+	 * 
+	 * @param id the source elements for the script
+	 */
+	public void setId(String id) {
+		generator.setId(id);
+	}
+
+	/**
+	 * Set the source elements for the script to be the given value.
+	 * 
+	 * @param type the source elements for the script
+	 */
+	public void setType(String type) {
+		generator.setType(type);
+	}
+	
+	/** 
+	 * Set the folder in which the build will occur.
+	 * @param buildDirectory the location where the build will occur.
+	 */
+	public void setBuildDirectory(String buildDirectory) {
+		generator.setWorkingDirectory(buildDirectory);
+	}
+	
+	/** 
+	 * Set the folder in which the build will occur.
+	 * @param buildId the location where the build will occur.
+	 */
+	public void setBuildId(String buildId) {
+		generator.setBuildId(buildId);
+	}
+}
