]> source.dussan.org Git - jquery-ui.git/commitdiff
Build: Minify i18n files and build a concatenated version; also fixing the double...
authorjzaefferer <joern.zaefferer@gmail.com>
Mon, 29 Mar 2010 16:58:38 +0000 (18:58 +0200)
committerjzaefferer <joern.zaefferer@gmail.com>
Mon, 29 Mar 2010 16:58:38 +0000 (18:58 +0200)
build/build.xml

index 6f225ca7b26027a4127b882adadefc8050c79d63..a99469b34f22efcab7d2df3a8728b305b448f89c 100644 (file)
        <property name="theme.dir" value="${ui.dir}/themes/base/" />
        <property name="docs.dir" value="${ui.dir}/docs/" />
 
-       <property name="min.folder" value="${dist.dir}/ui/minified" />
+       <property name="min.dir" value="${dist.dir}/ui/minified" />
 
        <property name="concatenated" value="jquery-ui" />
        <property name="concatenated.i18n" value="jquery-ui-i18n" />
 
        <property name="core.files" value="jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js" />
+       <property name="core.files.min" value="jquery.ui.core.min.js, jquery.ui.widget.min.js, jquery.ui.mouse.min.js, jquery.ui.draggable.min.js, jquery.ui.droppable.min.js, jquery.ui.resizable.min.js, jquery.ui.selectable.min.js, jquery.ui.sortable.min.js, jquery.effects.core.min.js" />
 
        <property description="Google Closure" name="closure-jar" value="${build.dir}/google-compiler-20091218.jar" />
        
-       <target name="deploy-release" depends="docs-download, concatenate, minify, copy, replace-version, prepend-header, zip" description="Release builder">
+       <target name="deploy-release" depends="clean, docs-download, concatenate, minify, copy, replace-version, prepend-header, zip" description="Release builder">
        </target>
-
+       
        <target name="replace-version">
                <replaceregexp match="@VERSION" replace="${release.version}" flags="g" byline="true">
                    <fileset dir="${dist.dir}/ui/" includes="*.js"/>
@@ -49,7 +50,6 @@
        </target>
        
        <target name="prepend-header">
-               <!-- TODO: refactor this ugly mess -->
                <copy todir="${dist.dir}/headers/">
                        <fileset dir="${dist.dir}/ui/" includes="*.js" />
                </copy>
@@ -57,7 +57,7 @@
                    <fileset dir="${dist.dir}/headers/" includes="*.js"/>
                </replaceregexp>
                <for param="file">
-                       <path><fileset dir="${dist.dir}/ui/minified/" includes="*.js" /></path>
+                       <path><fileset dir="${min.dir}/" includes="*.js" /></path>
                        <sequential>
                                <propertyregex override="yes" property="target" input="@{file}" regexp=".*[\\/](.+)\.min\.js$" replace="\1"/>
                                <concat destfile="${dist.dir}/ui-headered/${target}.min.js">
                                </concat>
                        </sequential>
                </for>
-               <copy todir="${dist.dir}/ui/minified">
+               <copy todir="${min.dir}">
                        <fileset dir="${dist.dir}/ui-headered/" includes="*.js" />
                </copy>
+               
+               <!-- once more for the i18n files -->
+               <!-- need to clean up headers in those files first
+               <copy todir="${dist.dir}/headers/i18n/">
+                       <fileset dir="${dist.dir}/ui/i18n/" includes="*.js" />
+               </copy>
+               <replaceregexp match="^(\/\*.*?\*\/\s).+" replace="\1" flags="s">
+                   <fileset dir="${dist.dir}/headers/i18n/" includes="*.js"/>
+               </replaceregexp>
+               <for param="file">
+                       <path><fileset dir="${min.dir}/i18n/" includes="*.js" /></path>
+                       <sequential>
+                               <propertyregex override="yes" property="target" input="@{file}" regexp=".*[\\/](.+)\.min\.js$" replace="\1"/>
+                               <concat destfile="${dist.dir}/ui-headered/i18n/${target}.min.js">
+                                       <header file="${dist.dir}/headers/i18n/${target}.js" />
+                                       <fileset file="@{file}" />
+                               </concat>
+                       </sequential>
+               </for>
+               <copy todir="${min.dir}/i18n/">
+                       <fileset dir="${dist.dir}/ui-headered/i18n/" includes="*.js" />
+               </copy>
+               -->
+
                <delete dir="${dist.dir}/headers/" />
                <delete dir="${dist.dir}/ui-headered/" />
        </target>
 
        <target name="minify" depends="concatenate" description="Remove all comments and whitespace, no compression, great in combination with GZip">
                <echo message="Building minified" />
-               <delete dir="${min.folder}/" />
-               <mkdir dir="${min.folder}" />
-               <delete dir="${min.folder}/i18n/" />
-               <mkdir dir="${min.folder}/i18n/" />
+               <delete dir="${min.dir}/" />
+               <mkdir dir="${min.dir}" />
+               <delete dir="${min.dir}/i18n/" />
+               <mkdir dir="${min.dir}/i18n/" />
                
                <apply executable="java" parallel="false">
                        <fileset dir="${src.dir}/" includes="jquery.ui.*.js, jquery.effects.*.js" />
                        <arg value="--js_output_file" />
                        <targetfile />
                        <arg value="--js" />
-                       <mapper type="glob" from="*.js" to="${min.folder}/*.min.js" />
+                       <mapper type="glob" from="*.js" to="${min.dir}/*.min.js" />
                </apply>
+
+               <concat destfile="${min.dir}/${concatenated}.min.js">
+                       <filelist dir="${min.dir}" files="${core.files.min}" />
+                       <fileset dir="${min.dir}" includes="jquery.ui.*.js, jquery.effects.*.js" excludes="${core.files.min}" />
+               </concat>
                
-               <apply executable="java" parallel="false" verbose="true" dest="${dist.dir}">
-                       <filelist dir="${dist.dir}/ui/" files="${concatenated}.js" />
+               <apply executable="java" parallel="false">
+                       <fileset dir="${src.dir}/i18n/" includes="jquery.ui.*.js" />
                        <arg line="-jar" />
                        <arg path="${closure-jar}" />
                        <arg value="--warning_level" />
                        <arg value="--js_output_file" />
                        <targetfile />
                        <arg value="--js" />
-                       <mapper type="glob" from="${concatenated}.js" to="tmpmin" />
+                       <mapper type="glob" from="*.js" to="${min.dir}/i18n/*.min.js" />
                </apply>
-               <concat destfile="${min.folder}/jquery-ui.min.js">
-                       <filelist files="${src.dir}/jquery.ui.core.js, ${dist.dir}/tmpmin"/>
-                       <filterchain>
-                               <headfilter lines="9"/>
-                       </filterchain>
-               </concat>
-               <concat destfile="${min.folder}/jquery-ui.min.js" append="yes">
-                       <filelist files="${dist.dir}/tmpmin"/>
+
+               <concat destfile="${min.dir}/i18n/${concatenated.i18n}.min.js">
+                       <fileset dir="${min.dir}/i18n" includes="jquery.ui.*.js" />
                </concat>
-               <delete file="${dist.dir}/tmpmin"/>
-               
+                               
                <echo message="Minified ui/ built." />
        </target>