Fixed 6219
authorStefan Hühner <stefan.huehner@openbravo.com>
Thu, 27 Nov 2008 14:33:40 +0000
changeset 2143 f924132f985c
parent 2142 1308ae534686
child 2144 d0ffb548ec2d
Fixed 6219
- Compress all JS/CSS files with the YUI compressor to reduce filesize
Can be disabled in Openbravo.properties
- exclude the compressors' jar-files from the WebContent as they are only needed at build-time
config/Openbravo.properties.template
legal/Licensing.txt
lib/build/YUIAnt.jar
lib/build/yuicompressor-2.4.2.jar
src/build.xml
--- a/config/Openbravo.properties.template	Thu Nov 27 14:22:54 2008 +0000
+++ b/config/Openbravo.properties.template	Thu Nov 27 14:33:40 2008 +0000
@@ -86,6 +86,9 @@
 # CSS Sprites Generator
 generateSprites=no
 
+# use js/css minimization (in local-context and war-file)
+minimizeJSandCSS=yes
+
 ##################
 # Authentication #
 ##################
--- a/legal/Licensing.txt	Thu Nov 27 14:22:54 2008 +0000
+++ b/legal/Licensing.txt	Thu Nov 27 14:33:40 2008 +0000
@@ -79,6 +79,10 @@
 Under Apache Software License 1.1, available at
 http://www.apache.org/licenses/LICENSE-1.1
 
+# YUI compressor (tool used at build-time to optionally minimize js/css files)
+# yuicompressor-2.4.2.jar
+# YUIAnt.jar
+Copyright (c) 2007, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: (http://developer.yahoo.net/yui/license.txt)
 
 # ant-1.6.5.jar
 # ant-launcher.jar
Binary file lib/build/YUIAnt.jar has changed
Binary file lib/build/yuicompressor-2.4.2.jar has changed
--- a/src/build.xml	Thu Nov 27 14:22:54 2008 +0000
+++ b/src/build.xml	Thu Nov 27 14:33:40 2008 +0000
@@ -54,6 +54,21 @@
 -->
 
 <project name="openbravo sources" default="compile" basedir=".">
+
+  <path id="yuicompressor.classpath">
+    <fileset dir="../lib/build">
+      <include name="**/yuicompressor-2.4.2.jar"/>
+      <include name="**/YUIAnt.jar"/>
+    </fileset>
+  </path>
+  <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask">
+    <classpath refid="yuicompressor.classpath"/>
+  </taskdef>
+
+  <condition property="minimizeJSandCSSbool">
+    <istrue value="${minimizeJSandCSS}" />
+  </condition>
+
   <property name="webTab" value="all"/>
   <property name="tab" value="%"/>
 
@@ -352,6 +367,7 @@
       <istrue value="${generateSprites}" />
     </condition>
     <antcall target="generate.sprites" inheritAll="true" inheritrefs="true" />
+    <antcall target="minimizeJSandCSS" inheritAll="true" inheritrefs="true" />
   </target>
 	
 	<target name="generate.sprites" description="Performs CSS sprite processing" if="generateSpritesBool">
@@ -376,6 +392,28 @@
 	      </move>
 	  </target>
 
+  <target name="minimizeJSandCSS" description="minimize JS and CSS files" if="minimizeJSandCSSbool">
+    <yuicompress linebreak="300" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${base.context}/web" >
+      <fileset dir="${base.web}" >
+        <include name="**/*.js" />
+        <include name="**/*.css" />
+        <!-- The following scripts break in minification process -->
+        <exclude name="**/js/dojo/src/docs.js" />
+        <exclude name="**/js/dojo/src/hostenv_jsc.js" />
+        <exclude name="**/js/jscalendar/lang/calendar-al.js" />
+        <exclude name="**/js/jscalendar/lang/calendar-he-utf8.js" />
+        <exclude name="**/js/jscalendar/lang/calendar-hr.js" />
+        <exclude name="**/js/xinha/lang/**" />
+        <exclude name="**/js/xinha/plugins/**" />
+	<!-- dojotoolkit files are already compressd -->
+	<exclude name="**/dojotoolkit/**"/>
+	<!-- from old dojo, only compress main file -->
+	<exclude name="**/dojo/**"/>
+	<include name="js/dojo/dojo.js"/>
+      </fileset>
+    </yuicompress>
+  </target>
+
 	<target name="postwad">
 		<copy todir="${base.design}/design">
 			<fileset dir="${build.AD}" includes="**/*.xml" />