Build your customization dojo

来源:互联网 发布:淘宝解锁id的原理 编辑:程序博客网 时间:2024/05/12 07:57

1. Download the src version dojo from dojo's offical site.
http://download.dojotoolkit.org/release-1.5.0/dojo-release-1.5.0-src.zip

2. Make sure you have already install the Ant successfully. The version should bigger than 1.7.

3. Update the build.xml according the definition xml.
The core definition is already be marked as red.

<project name="DojoWAR" default="production" basedir=".">

 <!-- The directory where build artifacts are created -->
  <property name="dir.build" location="build"/>
    
 <!-- The directory where the war file will be placed -->
 <property name="dir.dist"  location="${dir.build}/dist"/>
 
 <target name="production" depends="buildDojoProfile, generateDistributable"/>
   
 <target name="generateDistributable"
  description="Builds the distributable Dojo War file">

  <!-- Build up the WAR  -->
  <mkdir dir="${basedir}/temp"/>
  <mkdir dir="${basedir}/build/dist"/>
     
  <war destfile="${dir.dist}/DojoWEB.war" >
    <zipfileset dir="${basedir}/WebContent/" includes="**/**" />
  </war>     
   
 </target>

 <target name="buildDojoProfile">
   <property name="dir.profile"
    location="${basedir}/dojo-release-1.5.0-src"/>
      
  <echo message="Building Dojo profile..."/>
      
      
  <!-- Start the profile build by forking a java process to run ShrinkSafe -->
  <java fork="true"
     dir="${dir.profile}/util/buildscripts"
     classname="org.mozilla.javascript.tools.shell.Main">
    <classpath>
      <pathelement location="${dir.profile}/util/shrinksafe/js.jar"/>
      <pathelement location="${dir.profile}/util/shrinksafe/shrinksafe.jar"/>
    </classpath>
    <arg value="${dir.profile}/util/buildscripts/build.js"/>
    <arg value="version=1.5.0"/>
    <arg value="profileFile=${dir.profile}/util/buildscripts/profiles/baseplus.profile.js"/>
    <arg value="action=release"/>
    <arg value="optimize=shrinksafe"/>
    <arg value="cssOptimize=comments.keepLines"/>
  </java>
  <!-- remove unused Dojo files and directories -->  
  <!-- that we don't want to include            -->
      
    <delete includeemptydirs="true">
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/tests/**/"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/demos/**/"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="util/**"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/*.psd"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/*.fla"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/*.svg"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/*.as"/>
        <fileset dir="${dir.profile}/release/dojo/dojo" includes="**/*.swf"/>
        <fileset dir="${dir.profile}/release/dojo/dijit/themes/"
        includes="**/themeTester*"/>
        <fileset dir="${dir.profile}/release/dojo/" includes="**/*.uncompressed.js"/>
     </delete>      

 <copy toDir="${basedir}/WebContent/">
   <fileset dir="${dir.profile}/release/dojo" excludes="**/util/**" />
 </copy>    
</target>

<!-- Simple cleanup -->
  <target name="clean" description="Cleans out build files">
    <delete dir="${dir.build}"/>       
      <delete dir="${basedir}/WebContent/dijit"/>
    <delete dir="${basedir}/WebContent/dojo"/>
      <delete dir="${basedir}/WebContent/dojox"/>      
      <delete file="${basedir}/WebContent/dojo_extraction_revision.txt"/>
      <delete file="${basedir}/WebContent/dojo_extraction.log"/>
      <delete file="${basedir}/WebContent/version.txt"/>      
  </target>
</project>

4. You can write your own definition like below. Put your required components to the definition file.
It already be marked as red.

dependencies = {
    layers: [
        {
            // This is a specially named layer, literally 'dojo.js'
            // adding dependencies to this layer will include the modules
            // in addition to the standard dojo.js base APIs.
            name: "dojo.js",
            dependencies: [
                "dijit.form.ValidationTextBox",
                "dijit.form.FilteringSelect",
                "dijit.form.DateTextBox",
                "dijit.Tooltip",
                "dijit.form.Button"

            ]
        }
    ],

    prefixes: [
        [ "dijit", "../dijit" ],
        [ "dojox", "../dojox" ]
    ]
}

5. Run Ant in the folder.

原创粉丝点击