[fusion-commits] r1498 - in trunk: . lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Sep 5 10:31:06 EDT 2008


Author: madair
Date: 2008-09-05 10:31:06 -0400 (Fri, 05 Sep 2008)
New Revision: 1498

Modified:
   trunk/BUILDING.TXT
   trunk/build.xml
   trunk/lib/SingleFile.js
Log:
closes #100: add targets to compress CSS,
optional AppDef property for singleFile build.xml
add property to rename the output file

Modified: trunk/BUILDING.TXT
===================================================================
--- trunk/BUILDING.TXT	2008-09-04 20:43:52 UTC (rev 1497)
+++ trunk/BUILDING.TXT	2008-09-05 14:31:06 UTC (rev 1498)
@@ -1,15 +1,17 @@
 Building Fusion
 
 Fusion uses Apache Ant for building and deploying the source code to a web 
-server for developers working from the CVS repository.  End users deploying a 
-packaged distribution zip file need not worry about building fusion.
+server for developers working from the SVN repository.  End users deploying a 
+packaged distribution zip file need not worry about building fusion.  
+A target is included for building a single file, compressed version of the 
+JavaScript and CSS files for optimizing performance of your fusion application.
 
 Ant is a Java application and therefore Java must be installed on the developers
 machine.  Download and install the latest release of Ant (http://ant.apache.org/).
 To use Ant, navigate to the directory containing the build.xml file (usually
 the root directory of the project) and execute one of the ant targets, e.g.:
 
-> ant deploy
+> ant compress
 
 For some tasks, external executable files are used and must be available for 
 execution on the PATH environment variable.
@@ -24,10 +26,38 @@
 clean   - removes the temporary build directory
 clean-all - executes the clean target and also removes the deployed application
             from the web server
-compress  - creates a compressed version of the fusion library
 dist      - creates a packaged ZIP file for distribution
 docs      - automatically generates class documentation from the source code
+concat    - concatenates all core Fusion files into a singleFile
+singleFile - creates a single file version of the fusion library.  
+            If the appDef property points to an ApplicationDefinition.xml file,
+            it will be converted to JSON and included in the resulting package.
+compress  - creates a compressed single file version of the fusion library.  
+            If the appDef property points to an ApplicationDefinition.xml file,
+            it will be converted to JSON and included in the resulting package.
+compressCSS  - creates a compressed single file version of CSS files listed in
+            the cssFiles property.
+            
+concatWithAppDef and concatNoAppDef are internal targets not intended for end users.
 
 
+Properties that can be set (and their defaults) include:
+<property name="sfName"  value="${build.home}/lib/fusionSF"/>
+<property name="cssOutput"  value="${sfName}"/>
+<property name="cssFiles"  value=""/>
+<property name="appDef"  value=""/>
 
+These properties can be assigned a value when ant is invoked by using the
+-D command line option, e.g.:
+
+C:\pathTo\fusion>ant compressCSS -DcssFiles="jx\lib\jx_combined.css,jx\css\jxskin-border.css"
+C:\pathTo\fusion>ant compress -DappDef=templates\mapguide\standard\ApplicationDefinition.xml
+
+File paths are relative to the current directory (where the build.xml file is).
+
+Don't include file suffixes with the sfName and cssOutput properties, 
+the suffix will be added automatically.
+
+
+
 $Id$
\ No newline at end of file

Modified: trunk/build.xml
===================================================================
--- trunk/build.xml	2008-09-04 20:43:52 UTC (rev 1497)
+++ trunk/build.xml	2008-09-05 14:31:06 UTC (rev 1498)
@@ -90,6 +90,9 @@
 
   <property name="jx-lib"  value="jx"/>
   <property name="YUIcompressor"  value="C:\YUI\yuicompressor-2.3.5\build\yuicompressor-2.3.5.jar"/>
+  <property name="sfName"  value="${build.home}/lib/fusionSF"/>
+  <property name="cssOutput"  value="${sfName}"/>
+  <property name="cssFiles"  value=""/>
 
 
 <!-- ==================== Prepare Target ================================== -->
@@ -192,12 +195,22 @@
   </target>
 
 <!-- =================== single file build ================================== -->
-  <target description="single file build" name="singleFile" depends="clean,prepare,appDef2Json">
-    <echo message="preparing single file build for ${appDef}"/>
-    <delete dir="${build.home}/lib/fusionSF.js"/>
+  <target description="single file build" name="singleFile" depends="concat,concatWithAppDef,concatNoAppDef">
+    <echo message="preparing single file build"/>
+  </target>
+
+  
+<!-- =================== concat build ================================== -->
+  <target description="concatenate core files into a single file" name="concat" depends="clean,prepare">
+    <echo message="concatenating core files"/>
+    <delete dir="${sfName}.js"/>
     
+    <!-- Fusion looks for it's own script name to set paths for other widgets
+        so replace the value to look for with the sfName used to create the file-->
+    <replace file="${build.home}/lib/fusion.js" token="lib/fusion" value="${sfName}"/>
+    
     <!-- merge everything into a single file -->
-    <concat destfile="${build.home}/lib/fusionSF.js" outputencoding="UTF-8">
+    <concat destfile="${sfName}.js" outputencoding="UTF-8">
         <filelist dir="${build.home}/lib" 
                   files=" SingleFile.js
                           fusion.js
@@ -219,53 +232,78 @@
                           Map.js"
         />
         <fileset dir="${build.home}/text" includes="**/*.json"/>
+        <filelist dir="${build.home}" files="configHeader.json config.json"/>
+    </concat>
+  </target>
+
+<!-- =================== concat all support files (no appdef supplied) ================================== -->
+  <target description="concatenate core files into a single file" name="concatNoAppDef" depends="prepare" unless="appDef">
+    <echo message="concatenating all widget and map layer files"/>
+    
+    <!-- merge everything into a single file -->
+    <concat destfile="${sfName}.js" outputencoding="UTF-8" append="true">
+        <fileset dir="${build.home}/widgets" includes="**/*.js"/>
+        <filelist dir="${build.home}" files="MapGuide/MapGuide.js MapServer/MapServer.js"/>
+    </concat>
+  </target>
+
+<!-- =================== concat support files included in AppDef ================================== -->
+  <target description="concatenate core files into a single file" name="concatWithAppDef" depends="prepare,appDef2Json" if="appDef">
+    <echo message="preparing single file build for ${appDef}"/>
+    
+    <!-- merge everything into a single file -->
+    <concat destfile="${sfName}.js" outputencoding="UTF-8" append="true">
         <filelist dir="${build.home}" files="${AppDef.Maps}"/>
         <filelist dir="${build.home}" files="${AppDef.Widgets}"/>
-        <filelist dir="${build.home}" files="appDef.json configHeader.json config.json"/>
+        <filelist dir="${build.home}" files="appDef.json"/>
     </concat>
     
+  </target>
+
+
+<!-- =================== Compress Target ================================== -->
+
+  <target description="Compress JS files" name="compress" depends="singleFile">
     <echo message="compressing..."/>
     <java jar="${YUIcompressor}" fork="true"
-          output="${build.home}/lib/fusionSF-compressed.js">
-        <arg value="${build.home}/lib/fusionSF.js"/>
+          output="${sfName}-compressed.js">
+        <arg value="${sfName}.js"/>
     </java>
     <!--exec executable="jsmin.exe" os="Windows Vista, Windows XP" 
-      input="${build.home}/lib/fusionSF.js" output="${build.home}/lib/fusionSF-compressed.js"/-->
+      input="${build.home}/lib/fusion-combined.js" output="${build.home}/lib/fusion-compressed.js"/-->
   </target>
 
-  
-<!-- =================== Compress Target ================================== -->
+<!-- =================== concat all CSS files ================================== -->
+  <target description="concatenate CSS files into a single file" name="concatCSS" depends="prepare">
+    <echo message="concatenating all CSS files"/>
+    
+    <!-- merge everything into a single file -->
+    <echo message="merging with ${cssFiles}"/>
+    <concat destfile="${cssOutput}.css">
+        <filelist files="${cssFiles}"/>
+        <fileset dir="${build.home}/widgets" includes="**/*.css" excludes="**/*scalebar*"/>
+    </concat>
+    
+    <java jar="${YUIcompressor}" fork="true"
+          output="${cssOutput}-compressed.css">
+        <arg value="${cssOutput}.css"/>
+    </java>
+  </target>
 
-  <target description="Compress JS files" name="compress" depends="prepare">
-    <echo message="Concatenating into -lib version"/>
-    <concat destfile="${build.home}/lib/fusion-combined.js" outputencoding="UTF-8">
-        <filelist dir="${build.home}/lib" 
-        files=" Error.js 
-                EventMgr.js
-                ApplicationDefinition.js
-                MGBroker.js 
-                Widget.js 
-                ButtonBase.js 
-                MenuBase.js
-                ButtonTool.js 
-                CanvasTool.js 
-                ClickTool.js 
-                RectTool.js 
-                Search.js
-                Map.js"
-                />
-        <fileset dir="${build.home}/MapGuide" includes="*.js"/>
-        <fileset dir="${build.home}/MapServer" includes="*.js"/>
-        <fileset dir="${build.home}/text" includes="**/*.json"/>
-        <fileset dir="${build.home}/widgets" includes="*.js **/*.js" excludes="Recenter.js"/>
+<!-- =================== concat and compress a list of CSS files ================================== -->
+  <target description="concatenate and compress CSS files into a single file" name="compressCSS" if="cssFiles">
+    <echo message="concatenating all CSS files"/>
+    
+    <!-- merge everything into a single file -->
+    <echo message="merging ${cssFiles}"/>
+    <concat destfile="${cssOutput}.css">
+        <filelist files="${cssFiles}"/>
     </concat>
-    <echo message="compressing..."/>
+    
     <java jar="${YUIcompressor}" fork="true"
-          output="${build.home}/lib/fusion-compressed.js">
-        <arg value="${build.home}/lib/fusion-combined.js"/>
+          output="${cssOutput}-compressed.css">
+        <arg value="${cssOutput}.css"/>
     </java>
-    <!--exec executable="jsmin.exe" os="Windows Vista, Windows XP" 
-      input="${build.home}/lib/fusion-combined.js" output="${build.home}/lib/fusion-compressed.js"/-->
   </target>
 
 <!-- ==================== Deploy ========================================== -->

Modified: trunk/lib/SingleFile.js
===================================================================
--- trunk/lib/SingleFile.js	2008-09-04 20:43:52 UTC (rev 1497)
+++ trunk/lib/SingleFile.js	2008-09-05 14:31:06 UTC (rev 1498)
@@ -1,7 +1,35 @@
-/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
- * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
- * full text of the license. */
+/**
+ * Fusion.SingleFile
+ *
+ * $Id: Widget.js 1377 2008-04-16 19:27:32Z madair $
+ *
+ * Copyright (c) 2008, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
 
+ /* ***************************************************************************
+ * This file gets included in the single file build process to adjust Fusion
+ * properties and methods.
+ *
+ * ***************************************************************************/
+ 
+
 var Fusion = {
     singleFile: true
 };



More information about the fusion-commits mailing list