Build your customization dojo

本文介绍如何从源代码下载并使用Ant构建定制版Dojo Toolkit的过程,包括更新构建文件、选择所需组件、清理无用文件及最终打包成WAR文件。

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值