Fix a potential error in the previous commit caused by the use of a separate index...
[jquery.git] / build.xml
index 5baad64..f6650f4 100644 (file)
--- a/build.xml
+++ b/build.xml
 <project name="jQuery" default="all" basedir=".">
-       
-       <!--
-       - Using this build file to create your own custom distribution -
-       
-       If you want to include jQuery on your site with a certain set of plugins,
-       follow these steps to create your custom build:
-       
-       1. Copy the plugins you need to the plugins folder (if you haven't already, checkout
-          the plugins folder from SVN.
-       2. Modify the PLUGINS property to include all plugins you want, see PLUGINS_ALL for syntax
-          eg. if you need form and tabs plugin, set the value for PLUGINS to this:
-          form/*.js, tabs/*.js
-       3. Execute the standard jquery and packed targets to build your distribution
 
-       TODO Using this build file to create docs for a single plugin
-       -->\r
-\r
-       <!-- SETUP -->
+       <loadfile property="version" srcfile="version.txt" />
+       <property name="PREFIX" value="." />
+       <property description="Folder for jquery and min target" name="dist" value="${PREFIX}/dist" />
 
-       <property description="Source Folder" name="SRC_DIR" value="src" />
-       <property description="Files executefor parsing etc." name="BUILD_DIR" value="build" />
-       <property description="Rhino JS Engine" name="JAR" value="${BUILD_DIR}/js.jar" />\r
-\r
-       <property description="Dir to look for plugins" name="PLUGIN_DIR" location="../plugins" />\r
-       <property description="Add single plugins here" name="PLUGINS" value="none" />
-       <property description="Add all plugins here" name="PLUGINS_ALL" 
-               value="button/*.js,center/*.js,cookie/*.js,form/*.js,greybox/*.js,interface/*.js,pager/*.js,tablesorter/*.js,tabs/*.js,tooltip/*.js" />\r
+       <property name="JQ" value="${dist}/jquery.js" />
+       <property name="JQ_MIN" value="${dist}/jquery.min.js" />
 
-       <property description="Target parent folder for built files" name="PREFIX" value="." />
-       <property description="Folder for docs target" name="DOCS_DIR" value="${PREFIX}/docs" />
-       <property description="Folder for test target" name="TEST_DIR" value="${PREFIX}/test" />
-       <property description="Folder for jquery, min, lite and packed target" name="DIST_DIR" value="${PREFIX}/dist" />
+       <loadfile property="sizzle-exports" srcfile="src/sizzle-jquery.js" />
 
-       <!-- Files names for distribution -->
-       <property name="JQ" value="${DIST_DIR}/jquery.js" />
-       <property name="JQ_LITE" value="${DIST_DIR}/jquery.lite.js" />
-       <property name="JQ_MIN" value="${DIST_DIR}/jquery.min.js" />
-       <property name="JQ_PACK" value="${DIST_DIR}/jquery.pack.js" />\r
-\r
-       <!-- MAIN -->\r
-\r
-       <target name="jquery" description="Main jquery build, set PLUGINS property to include plugins">
-               <echo message="Building ${JQ}" />
-               <mkdir dir="${DIST_DIR}" />
-               <concat destfile="${JQ}">\r
-                       <fileset dir="${SRC_DIR}" includes="intro.js" />
-                       <fileset dir="${SRC_DIR}" includes="jquery/*.js" />
-                       <fileset dir="${SRC_DIR}" includes="event/*.js" />
-                       <fileset dir="${SRC_DIR}" includes="fx/*.js" />
-                       <fileset dir="${SRC_DIR}" includes="ajax/*.js" />\r
-                       <fileset dir="${PLUGIN_DIR}" includes="${PLUGINS}" />\r
-                       <fileset dir="${SRC_DIR}" includes="outro.js" />
-               </concat>
-               <echo message="${JQ} built." />
-       </target>
+       <available property="qunit" file="test/qunit" />
+       <available property="sizzle" file="src/sizzle" />
 
-       <target name="jquery_with_plugins" description="Build jquery with all plugins, useful to full documentation">
-               <antcall target="jquery">
-                       <param name="PLUGINS" value="${PLUGINS_ALL}" />
-               </antcall>\r
-       </target>
+       <target name="all" depends="jquery,lint,min" />
 
-       <target name="lite" depends="jquery" description="Remove all /** */ comments">
-               <echo message="Building ${JQ_LITE}" />
-               <java jar="${JAR}" fork="true">
-                       <arg value="${BUILD_DIR}/build/lite.js" />
-                       <arg value="${JQ}" />
-                       <arg value="${JQ_LITE}" />
-               </java>
-               <echo message="${JQ_LITE} built." />
+       <target name="qunit-clone" unless="qunit">
+               <exec executable="git" outputproperty="git-qunit" >
+                       <arg line="clone git://github.com/jquery/qunit.git test/qunit" />
+               </exec>
+               <echo message="git clone qunit: ${git-qunit}" />
+       </target>
+       <target name="qunit-pull" if="qunit">
+               <exec executable="git" outputproperty="git-qunit" dir="test/qunit" >
+                       <arg line="pull origin master" />
+               </exec>
+               <echo message="git pull sizzle: ${git-qunit}" />
+       </target>
+       <target name="sizzle-clone" unless="sizzle">
+               <exec executable="git" outputproperty="git-sizzle" >
+                       <arg line="clone git://github.com/jeresig/sizzle.git src/sizzle" />
+               </exec>
+               <echo message="git clone sizzle: ${git-sizzle}" />
+       </target>
+       <target name="sizzle-pull" if="sizzle">
+               <exec executable="git" outputproperty="git-sizzle" dir="src/sizzle" >
+                       <arg line="pull origin master" />
+               </exec>
+               <echo message="git pull sizzle: ${git-sizzle}" />
        </target>
 
-       <target name="min" depends="jquery" description="Remove all comments and whitespace, no compression">
-               <echo message="Building ${JQ_MIN}" />
-               <java jar="${JAR}" fork="true">
-                       <arg value="${BUILD_DIR}/build/min.js" />
-                       <arg value="${JQ}" />
-                       <arg value="${JQ_MIN}" />
-               </java>
-               <echo message="${JQ_MIN} built." />
+       <target name="init" depends="qunit-clone,qunit-pull,sizzle-clone,sizzle-pull" />
+
+       <target name="selector" depends="init" description="Builds the selector library for jQuery from Sizzle.">
+               <copy file="src/sizzle/sizzle.js" tofile="src/selector.js" overwrite="true" />
+               <replaceregexp match="// EXPOSE(.*)&#10;" replace="// EXPOSE\1&#10;${sizzle-exports}" file="src/selector.js" />
+               <replaceregexp match="window.Sizzle(.*)&#10;" replace="" file="src/selector.js" />
        </target>
 
-       <target name="pack" depends="jquery" description="Remove all comments and whitespace and compress">
-               <echo message="Building ${JQ_PACK}" />
-               <java jar="${JAR}" fork="true">
-                       <arg value="${BUILD_DIR}/build/pack.js" />
-                       <arg value="${JQ}" />
-                       <arg value="${JQ_PACK}" />
-               </java>
-               <echo message="${JQ_PACK} built." />
-       </target>\r
-\r
-       <target name="pack_with_plugins" depends="jquery_with_plugins" description="Pack jquery with all plugins, not very useful">\r
-               <echo message="Building ${JQ_PACK}" />\r
-               <java jar="${JAR}" fork="true">\r
-                       <arg value="${BUILD_DIR}/build/pack.js" />\r
-                       <arg value="${JQ}" />\r
-                       <arg value="${JQ_PACK}" />\r
-               </java>\r
-               <echo message="${JQ_PACK} built." />\r
+       <target name="jquery" depends="init,selector" description="Main jquery build, concatenates source files and replaces @VERSION">
+               <echo message="Building ${JQ}" />
+               <mkdir dir="${dist}" />
+               <concat destfile="${JQ}">
+                       <fileset file="src/intro.js" />
+                       <fileset file="src/core.js" />
+                       <fileset file="src/support.js" />
+                       <fileset file="src/data.js" />
+                       <fileset file="src/queue.js" />
+                       <fileset file="src/attributes.js" />
+                       <fileset file="src/event.js" />
+                       <fileset file="src/selector.js" />
+                       <fileset file="src/traversing.js" />
+                       <fileset file="src/manipulation.js" />
+                       <fileset file="src/css.js" />
+                       <fileset file="src/ajax.js" />
+                       <fileset file="src/xhr.js" />
+                       <fileset file="src/transports/jsonp.js" />
+                       <fileset file="src/transports/script.js" />
+                       <fileset file="src/transports/xhr.js" />
+                       <fileset file="src/effects.js" />
+                       <fileset file="src/offset.js" />
+                       <fileset file="src/dimensions.js" />
+                       <fileset file="src/outro.js" />
+               </concat>
+               <replaceregexp match="@VERSION" replace="${version}" flags="g" byline="true" file="${JQ}" />
+               <exec executable="git" outputproperty="date">
+                       <arg line="log -1 --pretty=format:%ad" />
+               </exec>
+               <replaceregexp match="(\(\s*function\s*\(\s*jQuery\s*\)\s*\{)|(\}\s*\)\s*\(\s*jQuery\s*\)\s*;)" flags="g" replace="" file="${JQ}" />
+               <replaceregexp match="Date: " replace="Date: ${date}" file="${JQ}" />
+               <echo message="${JQ} built." />
        </target>
 
-       <target name="test" depends="jquery" description="Reads tests from source and compiles into html file, testsuite must be run on a webserver">
-               <echo message="Building Test Suite" />
-               <delete dir="${TEST_DIR}" />
-               <mkdir dir="${TEST_DIR}/data" />\r
-               <copy todir="${TEST_DIR}/data">\r
-                       <fileset dir="${BUILD_DIR}/test/data/" />\r
-               </copy>\r
-               <java jar="${JAR}" fork="true">
-                       <arg value="${BUILD_DIR}/test/test.js" />
-                       <arg value="${JQ}" />
-                       <arg value="${TEST_DIR}" />
-               </java>
-               <echo message="Test Suite built." />
+       <target name="lint" depends="jquery" description="Check jQuery against JSLint">
+               <exec executable="java">
+                       <arg line="-jar build/js.jar build/jslint-check.js" />
+               </exec>
        </target>
 
-       <target name="docs" depends="jquery" description="Reads inline docs from source and compiles into xml file">
-               <echo message="Building Documentation" />
-               <delete dir="${DOCS_DIR}" />
-               <mkdir dir="${DOCS_DIR}/data" />
-               <copy todir="${DOCS_DIR}" file="${BUILD_DIR}/docs/.htaccess" />
-               <mkdir dir="${DOCS_DIR}/js" />
-               <copy todir="${DOCS_DIR}/js">
-                       <fileset dir="${BUILD_DIR}/docs/js">
-                               <include name="**/*.js" />
-                       </fileset>
-               </copy>
-               <copy todir="${DOCS_DIR}/style">
-                       <fileset dir="${BUILD_DIR}/docs/style">
-                               <include name="**" />
+       <target name="min" depends="jquery" description="Remove all comments and whitespace, no compression, great in combination with GZip">
+               <echo message="Building ${JQ_MIN}" />
+               <apply executable="java" parallel="false" verbose="true" dest="${dist}">
+                       <fileset dir="${dist}">
+                               <include name="jquery.js" />
                        </fileset>
-               </copy>
-               <java jar="${JAR}" fork="true">
-                       <arg value="${BUILD_DIR}/docs/docs.js" />
-                       <arg value="${JQ}" />
-                       <arg value="${DOCS_DIR}" />
-               </java>
-               <echo message="Documentation built." />
-       </target>\r
-
-       <!-- TODO refactor to remove duplication with above -->\r
-       <target name="docs_with_plugins" depends="jquery_with_plugins">\r
-               <echo message="Building Documentation" />\r
-               <delete dir="${DOCS_DIR}" />\r
-               <mkdir dir="${DOCS_DIR}/data" />\r
-               <copy todir="${DOCS_DIR}" file="${BUILD_DIR}/docs/.htaccess" />\r
-               <mkdir dir="${DOCS_DIR}/js" />\r
-               <copy todir="${DOCS_DIR}/js">\r
-                       <fileset dir="${BUILD_DIR}/docs/js">\r
-                               <include name="**/*.js" />\r
-                       </fileset>\r
-               </copy>\r
-               <copy todir="${DOCS_DIR}/style">\r
-                       <fileset dir="${BUILD_DIR}/docs/style">\r
-                               <include name="**" />\r
-                       </fileset>\r
-               </copy>\r
-               <java jar="${JAR}" fork="true">\r
-                       <arg value="${BUILD_DIR}/docs/docs.js" />\r
-                       <arg value="${JQ}" />\r
-                       <arg value="${DOCS_DIR}" />\r
-               </java>\r
-               <echo message="Documentation built." />\r
+                       <arg line="-jar" />
+                       <arg path="build/google-compiler-20100917.jar" />
+                       <arg value="--warning_level" />
+                       <arg value="QUIET" />
+                       <arg value="--js_output_file" />
+                       <targetfile />
+                       <arg value="--js" />
+                       <mapper type="glob" from="jquery.js" to="tmpmin" />
+               </apply>
+               <concat destfile="${JQ_MIN}">
+                       <filelist files="${JQ}, ${dist}/tmpmin" />
+                       <filterchain>
+                               <headfilter lines="15" />
+                       </filterchain>
+               </concat>
+               <concat destfile="${JQ_MIN}" append="yes">
+                       <filelist files="${dist}/tmpmin" />
+               </concat>
+               <delete file="${dist}/tmpmin" />
+               <echo message="${JQ_MIN} built." />
        </target>
 
        <target name="clean">
-               <delete dir="${DOCS_DIR}" />
-               <delete dir="${TEST_DIR}" />
-               <delete dir="${DIST_DIR}" />
+               <delete dir="${dist}" />
+               <delete file="src/selector.js" />
+               <delete dir="test/qunit" />
+               <delete dir="src/sizzle" />
        </target>
 
-       <target name="all" depends="clean,jquery,lite,min,pack,docs,test">
-               <echo message="Build complete." />
+       <target name="openAjaxMetadata">
+               <property name="target" value="openAjaxMetadata-jquery-${version}.xml" />
+               <delete file="${dist}/jquery-*.xml" />
+               <get src="http://www.exfer.net/jquery/createjQueryXMLDocs.py?version=1.3" dest="${target}" />
+               <xslt includes="${target}" excludes="build.xml" destdir="./dist" style="build/style.xsl" extension=".xml" />
+               <delete file="${target}" />
        </target>
-       
-       <!-- Extra stuff for Tabs plugin -->
-       
-       <property name="TABS" value="${PLUGIN_DIR}/tabs/tabs.js" />
-       <property name="TABS_PACK" value="${DIST_DIR}/jquery.tabs.pack.js" />
-
-       <target name="pack_tabs">\r
-               <echo message="Building ${TABS_PACK}" />\r
-               <mkdir dir="${DIST_DIR}" />\r
-               <java jar="${JAR}" fork="true">\r
-                       <arg value="${BUILD_DIR}/build/pack.js" />\r
-                       <arg value="${TABS}" />\r
-                       <arg value="${TABS_PACK}" />\r
-               </java>\r
-               <echo message="${TABS_PACK} built." />\r
-       </target>\r
 
 </project>