Index: fluid-infusion/build-scripts/build.properties
===================================================================
--- fluid-infusion/build-scripts/build.properties	(revision 8866)
+++ fluid-infusion/build-scripts/build.properties	(working copy)
@@ -61,3 +61,37 @@
 <!-- Directories to exclude from JSLint validation -->
 excludeFromJSLint=**/lib*/
 
+<!-- set up directory locations -->
+base-dir=..
+products=${base-dir}/products
+build=${base-dir}/build
+pretreated=${build}/pretreated
+assembled=${build}/assembled
+licenses=${assembled}/licenses
+buildwar=${build}/war
+src=${base-dir}/src/webapp
+
+
+
+
+tests=${base-dir}/src/webapp/tests
+dist=${products}/dist
+src-dist=${products}/src-dist
+web-inf=${base-dir}/src/webapp/WEB-INF
+lint=${src}
+
+<!-- the filename for the package to output -->
+zipfile=infusion-${fluid_version}
+
+<!-- the filename of the documentation PDF -->
+pdf-file=Fluid-${fluid_version}.pdf
+    
+<!-- the filename of the war file -->
+warfile=fluid-components-${fluid_version}.war
+    
+<!-- properties for URL rewriting -->
+regexStartJS=&lt;script{1,1}?.*
+regexEndJS={1,1}?.*script>
+replaceRegexStartJS=[\/-z]*
+replaceRegexEndJS=&quot;
+fluidRegExp=framework/core/js/Fluid.js
\ No newline at end of file
Index: fluid-infusion/build-scripts/build.xml
===================================================================
--- fluid-infusion/build-scripts/build.xml	(revision 8866)
+++ fluid-infusion/build-scripts/build.xml	(working copy)
@@ -1,4 +1,4 @@
-<project name="Fluid" default="releaseBuild" basedir=".">
+<project name="Fluid" default="releaseBuilds" basedir=".">
     <description>
       Build a distributable package of Fluid Infusion.
         
@@ -19,147 +19,211 @@
     <property file="build.properties"/>
     <import file="buildutils.xml"/>
 
-  <!-- set up directory locations -->
-    <property name="base-dir" location=".." />
-    <property name="products" location="${base-dir}/products" />
-    <property name="src" location="${base-dir}/src/webapp" />
-    <property name="tests" location="${base-dir}/src/webapp/tests" />
-    <property name="dist" location="${products}/dist" />
-    <property name="src-dist" location="${products}/src-dist" />
-    <property name="build" location="${base-dir}/build" />
-    <property name="licenses" location="${build}/licenses" />
-    <property name="web-inf" location="${base-dir}/src/webapp/WEB-INF"/>
-    <property name="lint" location="${src}"/>
-
-    <!-- the filename for the package to output -->
-    <property name="zipfile" value="infusion-${fluid_version}" />
-
-    <!-- the filename of the documentation PDF -->
-    <property name="pdf-file" value="Fluid-${fluid_version}.pdf" />
-    
-    <!-- the filename of the war file -->
-    <property name="warfile" value="fluid-components-${fluid_version}.war" />
-    
-    <!-- properties for URL rewriting -->
-    <property name="regexStartJS" value="&lt;script{1,1}?.*" />
-    <property name="regexEndJS" value="{1,1}?.*script>" />
-    <property name="replaceRegexStartJS" value="[\/-z]*" />
-    <property name="replaceRegexEndJS" value="&quot;" />
-    <property name="fluidRegExp" value="framework/core/js/Fluid.js" />
-    
     <!-- task definition for JSLint -->
     <taskdef name="jslint" 
       classname="net.happygiraffe.jslint.ant.JSLintTask" 
       classpath="${jslint}" />
-  
+
+	<target name="cleanExceptPretreat">
+        <delete dir="${assembled}" />
+        <delete dir="${products}" />
+	</target>
+	
+    <target name="cleanExceptProducts">
+        <delete dir="${build}"/>
+    </target>
+		
     <!-- Set up the build directory structure -->
     <target name="init">
         <mkdir dir="${products}" />
-        <mkdir dir="${build}" />
-        <mkdir dir="${dist}" />
-        <mkdir dir="${src-dist}" />
+        <mkdir dir="${pretreated}" />
+        <mkdir dir="${assembled}" />
+        <mkdir dir="${buildwar}" />
         <mkdir dir="${licenses}" />
     </target>
-    
-    <!-- Minifies javascript and css files and puts them into the distribution -->
-    <target name="minifyBuild">
-      <echo>Minifying .JS files...</echo>
-      <antcall target="minify">
-        <param name="fromDir" value="${build}" />
-        <param name="toDir" value="${dist}" />
-        <param name="file-pattern" value="*.js" />
-        <param name="lineBreakArg" value="" />
-      </antcall>
-      
-      <echo>Minifying .CSS files...</echo>
-      <antcall target="minify">
-        <param name="fromDir" value="${build}" />
-        <param name="toDir" value="${dist}" />
-        <param name="file-pattern" value="*.css" />
-        <param name="lineBreakArg" value="--line-break 0" />
-      </antcall>
-    </target>    
-    
-    <target name="copyDistroFiles">
-      <copy todir="${toDir}">
-        <fileset dir="${base-dir}/src/webapp/">
-            <include name="demos/**/*" />
-            <include name="integration-demos/**/*" />
-            <include name="standalone-demos/**/*" />
-            <include name="tests/**/*" />
-        </fileset>
-      </copy>       
+
+	<!-- need to clean this up -->
+	<target name="setPretreat">
+		<echo> noMinify is ${noMinify} </echo>
+		<condition property="pretreat">
+		    <not>
+                <equals arg1="true" arg2="${noMinify}" />
+		    </not>
+		</condition>
+	</target>
+	
+	<target name="setSourceDir">
+        <condition property="sourceDir" value="${pretreated}">
+             <equals arg1="true" arg2="${pretreat}" />
+        </condition>
+        <condition property="sourceDir" value="${src}">
+        	<not>
+               <equals arg1="true" arg2="${pretreat}" />
+            </not>
+        </condition>		
     </target>
-        
-    <!-- Creates the release directory structure and zips it all up -->
-    <target name="package">
-      <echo>Zipping distribution bundle to ${dist}/${zipfile}</echo>
-      <zip destfile="${products}/${zipfile}.zip" 
-        basedir="${dist}"
-        includes="**/*"  excludes="*.zip" />
-              
-      <echo>Zipping source bundle to ${dist}/${zipfile}</echo>
-      <zip destfile="${products}/${zipfile}-src.zip" 
-        basedir="${src-dist}"
-        includes="**/*"  excludes="*.zip" />
+	
+	<target name="copyCoreToWorkingAndSeedPretreated">
+        <copy todir="${build}/working">
+          <fileset dir="${src}">
+          	<include name="components/**/*" />
+            <include name="framework/**/*" />
+            <include name="lib/**/*" />
+          </fileset>
+        </copy>	
+
+        <copy todir="${pretreated}">
+          <fileset dir="${src}">
+              <exclude name="components/**/*.js" />          	
+              <exclude name="components/**/*.css" />              
+              <exclude name="framework/**/*.js" />              
+              <exclude name="framework/**/*.css" />              
+              <exclude name="lib/**/*.js" />              
+              <exclude name="lib/**/*.css" />              
+          </fileset>
+        </copy> 
+	</target>
+	
+	<target name="alwaysMinify" depends="copyCoreToWorkingAndSeedPretreated">
+		<antcall target="minifyJsAndCss">
+            <param name="fromDir" value="${build}/working" />
+            <param name="toDir" value="${pretreated}" />
+        </antcall>
+	</target>
+
+	<target name="maybeMinify" if="pretreat">
+		<antcall target="alwaysMinify" />
+    </target>
+
+    <!-- Runs the javascript dependency resolver which sets $jsfile, $requiredDirectoriesSelector, $jsRegExp, $jsReplaceRegExp and $allRequiredJSFiles -->
+    <target name="resolveDependencies">
+        <script language="javascript" src="${base-dir}/build-scripts/build.js" />
     </target>
 
+    <target name="concatJavaScript">
+    	<echo> concat the javascript from ${sourceDir} </echo>
+        <concat destfile="${assembled}/${jsfile}" >
+            <filelist dir="${sourceDir}" files="${allRequiredJSFiles}" /> 
+        </concat>    
+    </target>
+	
+    <target name="assemble" depends="concatJavaScript">
+    	<echo> Coping from ${sourceDir} to ${assembled} </echo>
+        <copy todir="${assembled}">
+            <fileset dir="${sourceDir}" includes="${requiredDirectoriesSelector}">
+                <exclude name="**/*LICENSE.txt" />
+            	<exclude name="**/*Dependencies.json" />
+            </fileset>
+        </copy>
+        <copy file="${base-dir}/README.txt" todir="${assembled}" />
+        <copy todir="${licenses}" flatten="true">
+            <fileset dir="${base-dir}">
+                <include name="**/*LICENSE.txt" />
+                <exclude name="${build}" />
+                <exclude name="${products}" />
+            </fileset>
+        </copy>
+    </target> 
+
+	<target name="assembleFull" depends="assemble">
+        <copy todir="${assembled}">
+            <fileset dir="${sourceDir}">
+                <include name="*demos/**" />
+                <include name="tests/**" />
+            </fileset>
+        </copy>
+		   
+	</target>
+	
+	<target name="copyMavenWARFiles">
+		<copy todir="${buildwar}/src/webapp/WEB-INF" >
+		        <fileset dir="${web-inf}"/>
+		      </copy>
+		  
+		      <copy todir="${buildwar}">
+		        <fileset dir="${base-dir}">
+		          <include name="pom.xml" />
+		          <include name="project.xml" />
+		          <include name="maven.xml" />
+		          <include name="project.properties" />
+		        </fileset>
+		      </copy>
+	</target>
+	
     <!-- Copies the files required to build a war file containing Infusion. -->
-    <target name="copyInfusionWARFiles">        
-      <copy todir="${build}/war/src/webapp/" >
-        <fileset dir="${fromDir}">
+    <target name="copyCoreWARFiles" depends="copyMavenWARFiles">        
+      <copy todir="${buildwar}/src/webapp/" >
+        <fileset dir="${assembled}">
             <include name="components/**/*" />
             <include name="framework/**/*" />
             <include name="lib/**/*" />          
         </fileset>
-      </copy>
-  
-      <copy todir="${build}/war/src/webapp/WEB-INF" >
-        <fileset dir="${web-inf}"/>
-      </copy>
-  
-      <copy todir="${build}/war">
-        <fileset dir="..">
-          <include name="pom.xml" />
-          <include name="project.xml" />
-          <include name="maven.xml" />
-          <include name="project.properties" />
-        </fileset>
-      </copy>
+      </copy>    
     </target>
-    
+	
     <!-- Builds the core Infusion WAR file. -->
-    <target name="buildInfusionWAR">
-        <antcall target="copyInfusionWARFiles">
-            <param name="fromDir" value="${dist}" />
+    <target name="buildCoreWAR" depends="copyCoreWARFiles">        
+        <antcall target="buildWAR">
+            <param name="fromDir" value="${buildwar}" />
+            <param name="toFile" value="${assembled}/${warfile}" />
+            <param name="warFile" value="${warfile}" />
         </antcall>
-        
+    </target>
+	
+	<target name="buildFullWAR" depends="copyMavenWARFiles">
+		<copy todir="${buildwar}/src/webapp/" >
+		        <fileset dir="${assembled}" />
+		</copy>
+		
         <antcall target="buildWAR">
-            <param name="fromdir" value="${build}/war" />
-            <param name="tofile" value="${dist}/${warfile}" />
-            <param name="warfile" value="${warfile}" />
+            <param name="fromDir" value="${buildwar}" />
+            <param name="toFile" value="${assembled}/${warfile}" />
+            <param name="warFile" value="${warfile}" />
+        </antcall>	
+	</target>
+	
+    <target name="zip">
+      <echo>Zipping bundle to ${products}/${zipfile}</echo>
+      <zip destfile="${products}/${zipfile}.zip" 
+        basedir="${assembled}"
+        includes="**/*"  excludes="*.zip" />
+    </target>
+	
+	<target name="customBuild" depends="clean, init, setPretreat, setSourceDir, maybeMinify, resolveDependencies, assemble, buildCoreWAR, zip" 
+        description="Builds a custom package of Infusion containing the modules specified as command line arguments.">
+    </target>
+	
+    <target name="pretreatMinify" depends="clean, init, alwaysMinify"
+	    description="Minifies everything to prepare for builds done from pretreated source">
+    </target>
+    	
+	<target name="builderBuild" depends="cleanExceptPretreat, init, setPretreat, setSourceDir, resolveDependencies, assemble, buildCoreWAR, zip" 
+        description="Builds a custom package of Infusion containing the modules specified by the builder.">
+    </target>
 
-        </antcall>
+	<!-- we don't really have dependencies but we need a list of all the files to concat and the resolve depedencies task makes that. -->
+    <target name="dailyBuild" depends="clean, init, setSourceDir, resolveDependencies, assembleFull, buildFullWAR"
+        description="Builds and packages Infusion along with tests and sample code, suitable for development testing or a daily build.">
+    	<copy file="${assembled}/${warfile}" todir="${products}" />
     </target>
-        
-    <!-- Builds a full-fledged WAR file used for the daily build, which includes sample code and tests. -->
-    <target name="buildDailyWAR">
-        <antcall target="copyInfusionWARFiles">
-            <param name="fromDir" value="${src-dist}" />
-        </antcall>
+	
+	<target name="releaseBuild" depends="cleanExceptProducts, init, setPretreat, setSourceDir, maybeMinify, resolveDependencies, assembleFull, buildCoreWAR, zip"/>
 
-        <!-- Copy the additional files into the war build required for the daily build. -->
-        <antcall target="copyDistroFiles">
-            <param name="toDir" value="${build}/war/src/webapp/" />
-        </antcall>
-        
-        <antcall target="buildWAR">
-            <param name="fromdir" value="${build}/war" />
-            <param name="tofile" value="${src-dist}/${warfile}" />
-            <param name="warfile" value="${warfile}" />
+    <target name="releaseBuilds" depends="clean" 
+        description="Builds and packages a release bundle of Infusion.">
+    	<antcall target="releaseBuild">
+    	   <param name="noMinify" value="true" />
         </antcall>
+    	<copy file="${products}/${zipfile}.zip" tofile="${products}/${zipfile}-src.zip" />
+    	<antcall target="releaseBuild" />
     </target>
-
+    
+	<target name="infusionAllBuilds" depends="clean, init">
+        <!-- rewrite the heads then kick off two builds which maybe minify, assemble and make zip -->
+	</target>
+	
+	
+	
     <!-- Target: validate -->
     <target name="validate" description="Validates all JavaScript files using JSLint. To lint a specific folder use: -Dlint=../some/folder" >
 
@@ -170,49 +234,7 @@
         </jslint>
     </target>
     
-    <target name="concatJavaScript" >
-        <concat destfile="${build}/${jsfile}" >
-            <filelist dir="${src}" files="${allRequiredJSFiles}" /> 
-        </concat>    
-    </target>
-    
-    <!-- Runs the javascript dependency resolver which sets $jsfile, $requiredDirectoriesSelector, $jsRegExp, $jsReplaceRegExp and $allRequiredJSFiles -->
-    <target name="resolveDependencies" depends="clean">
-        <script language="javascript" src="${base-dir}/build-scripts/build.js" />
-    </target>
 
-    <target name="copyToSrcBundle" depends="copySourceToBuild">        
-        <copy todir="${src-dist}">
-            <fileset dir="${build}" />
-        </copy>
-    </target>
-    
-    <target name="copyToDeployBundle" depends="copySourceToBuild">        
-        <!-- Copy everything but the JavaScript and CSS we are about to minify -->
-        <!-- Also exclude the dependency json files from the distribution -->
-        <copy todir="${dist}">
-          <fileset dir="${build}" excludes="**/*.js,**/*.css, **/*Dependencies.json" />
-        </copy>
-        
-        <!-- Minify and copy JavaScript and CSS into the build directory -->
-        <antcall target="minifyBuild" />
-    </target>
-
-    <!-- Builds a complete source release bundle. -->
-    <target name="buildSrcBundle" depends="copyToSrcBundle">        
-        <antcall target="copyDistroFiles">
-            <param name="toDir" value="${src-dist}" />
-        </antcall>
-    </target>
-    
-    <!-- Builds a complete minified deployment release bundle. -->
-    <target name="buildDeployBundle" depends="copyToDeployBundle">        
-        <!-- Create the build products -->
-        <antcall target="copyDistroFiles">
-            <param name="toDir" value="${dist}" />
-        </antcall>
-    </target>
-    
     <!-- Replaces the first occurence of a file that is in the single js file, with the reference to the single js file. 
     Depends on the build already being deployed (i.e. through buildDeployBundle or copyToDeployBundle) -->
     <target name="replaceJS">
@@ -240,32 +262,5 @@
         <antcall target="removeJS" />
     </target>
     
-    <target name="copySourceToBuild" depends="clean, init, resolveDependencies, concatJavaScript">
-        <copy todir="${build}">
-            <fileset dir="${src}" includes="${requiredDirectoriesSelector}">
-                <exclude name="**/*LICENSE.txt" />
-            </fileset>
-        </copy>
-        <copy file="${base-dir}/README.txt" todir="${build}" />
-        <copy todir="${licenses}" flatten="true">
-            <fileset dir="${base-dir}">
-                <include name="**/*LICENSE.txt" />
-                <exclude name="${build}" />
-                <exclude name="${products}" />
-            </fileset>
-        </copy>
-    </target> 
-
-    <target name="releaseBuild" depends="buildSrcBundle, buildDeployBundle, rewriteHTMLHead, buildInfusionWAR, package" 
-        description="Builds and packages a release bundle of Infusion.">
-    </target>
-    
-    <target name="dailyBuild" depends="buildSrcBundle, buildDeployBundle, rewriteHTMLHead, buildDailyWAR, package"
-        description="Builds and packages Infusion along with tests and sample code, suitable for development testing or a daily build.">
-    </target>
-
-    <target name="customBuild" depends="copyToSrcBundle, copyToDeployBundle, rewriteHTMLHead, buildInfusionWAR, package" 
-        description="Builds a custom package of Infusion containing the modules specified as command line arguments.">
-    </target>
     
 </project>
Index: fluid-infusion/build-scripts/buildutils.xml
===================================================================
--- fluid-infusion/build-scripts/buildutils.xml	(revision 8866)
+++ fluid-infusion/build-scripts/buildutils.xml	(working copy)
@@ -3,29 +3,26 @@
         Utilities used by the Infusion and Engage builds
     </description>
 
+
     <target name="clean" description="Cleans up all build-related artifacts and products.">
         <delete dir="${build}" />
         <delete dir="${products}" />
     </target>
 
-    <target name="buildWAR" description="Builds a WAR file using maven given 3 parameters. tofile: the full path to the warfile to be created; fromdir: the directory containing the content to be placed in the war; warfile: the name of the warfile that is created from the maven task">
+    <target name="buildWAR" description="Builds a WAR file using maven given 3 parameters. toFile: the full path to the warfile to be created; fromDir: the directory containing the content to be placed in the war; warFile: the name of the warfile that is created from the maven task">
       <condition property="isWindows">
         <os family="windows" />
       </condition>
-      <antcall target="invokeMavenForWAR">
-          <param name="fromdir" value="${fromdir}" />
-      </antcall>
-      <antcall target="invokeMavenForWARWindows">
-          <param name="fromdir" value="${fromdir}" />
-      </antcall>
+      <antcall target="invokeMavenForWAR" />
+      <antcall target="invokeMavenForWARWindows" />
       <echo>Copying war file ...</echo>
-      <copy tofile="${tofile}" file="${fromdir}/target/${warfile}" />
+      <copy tofile="${toFile}" file="${fromDir}/target/${warFile}" />
     </target>
 
-    <!-- Uses maven to create a WAR file on a non-Windows operating system. Expects 'fromdir' to be set. -->
+    <!-- Uses maven to create a WAR file on a non-Windows operating system. Expects 'fromDir' to be set. -->
     <target name="invokeMavenForWAR" unless="isWindows">
-      <echo>Building war file... ${fromdir} </echo>
-      <apply executable="mvn" dir="${fromdir}" parallel="true">
+      <echo>Building war file... ${fromDir} </echo>
+      <apply executable="mvn" dir="${fromDir}" parallel="true">
           <fileset  dir=".">
               <include name="pom.xml"/>
           </fileset>
@@ -33,9 +30,9 @@
       </apply>
     </target>
   
-    <!-- Uses maven to create a WAR file on a Windows operating system. Expects 'fromdir' to be set. -->
+    <!-- Uses maven to create a WAR file on a Windows operating system. Expects 'fromDir' to be set. -->
     <target name="invokeMavenForWARWindows" if="isWindows">
-      <apply executable="cmd" dir="${fromdir}" parallel="true" vmlauncher="false">
+      <apply executable="cmd" dir="${fromDir}" parallel="true" vmlauncher="false">
           <fileset  dir=".">
               <include name="pom.xml"/>
           </fileset>
@@ -43,11 +40,13 @@
       </apply>
     </target>
 
+	<!-- Expects toDir, fromDir, filePattern, lineBreakArg to be set -->
     <target name="minify">
+    	<echo> Going to minify from ${fromDir} to ${toDir} including ${filePattern}  </echo>
         <apply executable="java" dest="${toDir}"  parallel="false">
             <!-- The files to act upon. -->  
             <fileset dir="${fromDir}" casesensitive="no">
-              <include name="**/${file-pattern}" />
+              <include name="**/${filePattern}" />
               <exclude name="**/test/*" />
             </fileset>
     
@@ -58,9 +57,22 @@
             <!-- -o option for YUI Compressor to output minified JS to a file instead of stdout. -->
             <arg line="${lineBreakArg}" />
             <arg line="-o" />
-            <mapper type="glob" from="${file-pattern}" to="${file-pattern}" />
+            <mapper type="glob" from="${filePattern}" to="${filePattern}" />
             <targetfile /> 
         </apply>
     </target>    
     
+    <!-- Minifies javascript and css files. Expects fromDir and toDir to be set -->
+    <target name="minifyJsAndCss">
+      <echo>Minifying .JS files...</echo>
+      <antcall target="minify">
+        <param name="filePattern" value="*.js" />
+        <param name="lineBreakArg" value="" />
+      </antcall>
+      
+      <antcall target="minify">
+        <param name="filePattern" value="*.css" />
+        <param name="lineBreakArg" value="--line-break 0" />
+      </antcall>
+    </target>    
 </project>
