星空网 > 软件开发 > ASP.net

【ANT】Ant常用的内置task

 

  • ant

例如: 

<target name="callProjectB">  <echo message="In projectA calling projectB"/>       <ant antfile="subfile/projectB. /> </target>

说明:项目A通过ant命令执行项目B

属性:

(1) antfile : 指定要执行的构建文件名称,可以包含路径信息。

(2) dir : 指定构建文件所在的目录,相当于指定了要执行的构建文件的basedir属性,如果dir属性没有设置,会以当前构建文件的根目录作为ant任务的根目录。

(3) Target:指定要执行的构建文件要执行的target。例如

【ANT】Ant常用的内置task【ANT】Ant常用的内置task
<project name="porjectA" default="callProjectB">    <target name="callProjectB">         <echo message="In projectA calling projectB"/>              <ant antfile="subfile/projectB. target=" target2"/>     </target></project>

View Code

(4) output :指定ant工具执行时的信息输出,可定位到控制台或者文件中,当定位到文件中相当于在命令行指定了-logfile filename。

<ant antfile="subfile/projectB. output="out.log"/>

(5) inheritAll:如果设定为true,那么被调用的构建文件的project元素中可使用当前project中的reference任务。Reference任务的作用是吧当前属性复制到被调用的ant project中使用,reference任务包含两个属性:

    refid :代表当前project中的属性id。

    Torefid :用于指定在被调用的project中的引用id。

例如:

<reference refid="path1" torefid="path2"/>  <!-- // 把当前project中的path1属性传递给被调用的project中使用, 在被调用project中通过path2引用这个属性。 -- >

  • antcall : 执行过程中调用并执行其他target

    例如:

    <target name="targetA">     <echo message="In targetA calling targetB"/>       <antcall target="targetB" >       </antcall>         <echo message="After call targetB" /> </target>

    属性:

    (1) target:在AntCall任务中target属性的作用是指定要被调用执行的target,通过名称指定这个target属性是必需的。值得注意的是,当通过AntCall任务调用的target存在依赖的target(depends中指定了target),则depends属性中被指定的target也会被执行。

        (2) inheritAll :用于指定是否继承当前的属性。默认时为true,代表被调用的target可使用这些属性。

        (3) inheritRefs :用于指定是否覆盖reference属性或者是否建立一个对当前reference属性的引用。在默认的情况下,AntCall任务不会覆盖reference属性,除非把inheritRefs属性设为true。默认时inheritRefs属性为false。

       例如:利用AntCall Task实现target间调用时传递参数的实例  当需要从一个target传递参数到被调用的target时,可以使用<param> 类型进行传递。当然也可以在target中定义property来实现,与Java中的方法调用时传递参数相似

【ANT】Ant常用的内置task【ANT】Ant常用的内置task
<target name="targetA">     <echo message="In targetA calling targetB"/>    <!-- //通过property传递 -->      <property name="prop" value="prop property" />     <antcall target="targetB" >      <!-- // 通过antcall设定param实现 -->      <param name="path1" value="path1 param" />    </antcall>     <echo message="After call targetB" /> </target>  <target name="targetB" depends="init">   <echo message="In targetB" />    <echo message="path1=${path1}" />   <echo message="prop=${prop}" /> </target>

View Code

      通过property指定和通过AntCall中的param指定的属性都传递到targetB中,对于param类型只有两个属性:name和value。由于AntCall任务中的inheritAll属性默认时为true,所以property能被targetB引用。如果targetB中也定义了相同的property,那么         可以通过设置inheritRefs属性和reference类型进行覆盖。

  • Apply/ExecOn : ant工具直接执行系统命令

    Apply/ExecOn 任务的作用是,通过Ant工具直接执行系统使命。通过这个task执行的命令依赖于操作系统,而且只能在Ant支持的操作系统下执行。Ant支持WindowsLinux、UNIX、OS/2 Warp、Novell Netware 6和MacOS X。

    属性:

    (1) executable :用于指定要执行的命令,不带命令行参数,这个属性是必需的。

    (2) dest :用于指定命令执行时目标文件的存放位置。

    (3) spawn :用于指定是否在执行命令时产生输出信息。默认为false代表输出日志信息。如果指定了spawn属性为true,Ant将不会产生这个命令的日志输出。 

    (4) dir :用于指定执行命令所在的目录,在此目录下执行这个命令。 

    (5) relative:用于指定命令是否支持相对路径。默认为false,不支持相对路径,相对于当前根目录或dest属性设定的目录。

    (6) forwardslash:用于设定文件路径是否支持斜线分隔符,尽管有些操作系统支持其他的分隔符。默认时为false,如果操作系统的分隔符为斜线,那么这个属性将被忽略。 

    (7) os:列出允许执行这个命令的操作系统。

    (8) output:指定把命令行执行的输出重定向到一个输出文件。如果错误信息没有重定向到特定文件,错误信息则将输出到这个文件中。

    (9) error :指定一个文件用于接收错误的输出信息。从Ant 1.6后提供了这个     属性。 

    (10) logError:这个属性用于指定把错误的日志输出到Ant工具的日志信息中,也可以通过error属性指定错误的输出文件。

    (11) append:指定是否可以输出到一个存在的文件或者覆盖存在的文件,默认为false。 

    (12) outputproperty:指定输出定向到的属性的名字,在属性中可定义一个文件,这样就可以把输出信息输出到文件中。 

    (13) errorproperty:用于指定把错误信息输出到的属性的名字。

    (14) input:指定一个文件,从这个文件中读取属性,在执行命令时可以引用得到这些属性。

    (15) inputstring:用于把inputstring属性指定的字符串传递给执行的命令。

    (16) resultproperty:这个属性用于存放命令执行后所返回的结果。 

    (17) timeout:设定一个时间,如果这段时间内命令没执行完毕,则这个命令会被中断。

    (18) failonerror:这个属性用于指定是否出错时命令终止。如果属性取值为true,那么在执行的命令退出的同时返回一个不为0的代码,则构建进程将会中止。

    (19) failifexecutionfails :用于指定当不能执行程序时是否中止构建命令的执行,默认为true。 

    (20) skipemptyfilesets:当指定的目录中没有文件,则构建命令将不会被执行。 

    (21) parallel:如果属性为true,则构建命令只执行一次,并把附加的文件作为命令参数。如果为false则每一个附加的文件都会执行一次这个命令。默认为false。  

    (22) type :指定传给要执行的命令的参数类型,可为file(文件)、dir(目录)、path(路径)。默认为file。 

    (23) newenvironment:如果当前的环境变量被声明,将不传递旧的环境变量,默认为false。 

    (24) vmlauncher :默认为true,通过Java虚拟机的特性来执行构件文件。如果为false,则通过操作系统本身的脚本功能去执行。  

    (25) resolveExecutable:默认为false,如果设为true,那么命令会在project的根目录下执行。如果在UNIX或Linux下只允许用户在自己的路径下执行这个命令,那么要把这个属性设为false。  

    (26) maxparallel :设定一个最大的平行值,用于指定一次执行的源文件的最大数目。如果设为<0代表没有限制。默认为没有限制。  

    (27) addsourcefile:是否自动添加源文件名到执行的命令中,默认为true。

    (28) verbose :是否输出命令执行时的概要信息,默认为false不输出。

    (29) ignoremissing :是否忽略不存在的文件,默认为true。 

    (30) force :是否通过timestamp来对target文件进行对比。默认为false。

    Apply/ExecOn Task可使用的参数 

    执行Apply/ExecOn 任务时可以通过Ant提供的一些内置类型来简化操作,类似于参数传递的作用。可使用的Ant类型有:    

    ● FileSet:可以通过<fileset>元素来设定文件集合,在任务中引用这个FileSet。   

    ● FileList:可以通过一个或多个FileList来指定文件列表,然后在Apply/ExecOn Task中进行引用。   

    ● Dirset:通过Dirset定义目录集合,然后在Apply/ExecOn Task中进行引用。    

    ● Arg:可通过<arg>类型指定命令行参数,然后在Apply/ExecOn Task中使用。    

    ● Mapper:通过Mapper类型可以指定dest属性的文件的映射关系。   

    ● Srcfile:通过参数指定源文件,在<arg>的后面使用,<arg>参数的值为Srcfile指定的源文件。    

    ● Targetfile:与Srcfile作用相似,用于指定目录文件的参数。    

    ● Env:指定一个环境变量,并在命令行中传递,以<env>类型的形式使用。

    通过Apply/ExecOn Task执行Linux下ls命令 (显示文件信息)的实例。  在Linux系统中,可以通过ls的shell命令显示文件的详细信息。用Ant工具也可以执行ls这个功能。具体的例子如下: 

    <apply executable="ls">  <arg value="-l"/>  <fileset dir="/tmp">    <patternset>       <exclude name="**/*.txt"/>    </patternset>  </fileset>   <fileset refid="other.files"/></apply>

    这个例子的作用是:调用ls–l的shell命令,列出/tmp目录下的所有非.txt文件和所有id为other.files的FileSet类型所指定的文件的详细信息。

    使用Mapper、Srcfile类型的实例   下面是一个通过Apply/ExecOn任务使用Mapper和Srcfile类型的例子,具体内容如下:  

    <apply executable="cc" dest="src/C" parallel="false">    <arg value="-c"/>    <arg value="-o"/>    <targetfile/>    <srcfile/>        <fileset dir="src/C" includes="*.c"/>    <mapper type="glob" from="*.c" to="*.o"/> </apply>

    这个例子的作用是:通过Mapper指定为每个比.o文件新的.c文件执行cc –c –o targetfile sourcefile命令。在这个命令中用.o文件的名称替换targetfile(目标文件),用.c文件的名称替换sourcefile

  • Chmod Task : 改变Linux/Unix系统的文件权限

    在UNIX和Linux系统下要改变文件的权限,可以使用chmod的shell命令。例如:chmod 777 abc.txt。设置abc.txt文件的权限为“所有人有对文件操作的所有权限”。在Ant工具中可以通过Chmod任务方便地实现这些功能。在Chmod任务中可以引用FileSet和DirSet类型指定的文件集合和目录集合。 

    Chmod Task属性及功能  Chmod任务包括如下属性:  

    (1)file:用于指定即将被改变权限的文件名称。  

    (2)dir:用于指定这个目录下的所有文件的权限将要被改变。在Chmod任务中dir属性和file属性两者必须选择其中一个。 

    (3)perm:用于指定文件的新权限。  

    (4)includes:用于指定一个或多个文件的匹配模式,只有符合这些模式的文件的权限才会被改变。可用逗号符或空格符进行分隔。  

    (5)excludes:与includes属性的作用正好相反,用于指定一个或多个文件匹配模式,只有不符合这些模式的文件的权限才会被改变。可用逗号符或空格符进行分隔。 

    (6)defaultexcludes:用于指定是否不包括Ant工具默认不包含的文件匹配模式。可取值为yes或no。忽略此属性时代表不包含默认的不包含的文件模式。  Ant工具默认不包含的文件模式有:**/*~,**/#*#,**/.#*,**/%*%,**/._*, **/CVS,**/CVS/**,**/.cvsignore,**/SCCS,**/SCCS/**,**/vssver.scc,**/.svn,**/.svn/**,**/.DS_Store。   (7)parallel:用于指定是否为每个包含的文件独立执行Chmod命令,默认为true。  

    (8)type:可取值为file、dir或both。取值file表示只改变文件的权限;若取值dir表示只改变目录的权限;若取值both则代表改变文件和目录两者的权限。  

    (9)maxparallel:用于指定一次执行Chmod命令的最大值。设为<=0代表不限制,默认为不限制。

    (10)verbose:用于指定在执行命令后是否输出这个命令的执行信息。默认为false不输出。  

    通过Ant改变Linux/UNIX文件和目录权限的例子

       在Linux和UNIX下通常通过Chmod命令来改变文件或目录的权限,Ant工具的Chmod任务也能实现同样的功能。例如,改变start.sh文件的权限让所有人对此文件具有读和执行的权限。   <chmod file="${dist}/start.sh" perm="ugo+rx"/>   所有用户对${dist}/start.sh文件都具有读和执行的权限。如果只有文件的所有者才具有读、写和执行权限,那么可以编写以下程序: 

    <chmod file="${dist}/start.sh" perm="o+rx"/>  

    当然也可以用数据来表示权限,上面的程序可改为:   <chmod file="${dist}/start.sh" perm="700"/> <!--  //与上面程序作用相同,   文件的所有者才具有读、写和执行的权限  -->   当然也可以通过FileSet和DirSet类型实现更复杂的功能,例如: 

    <chmod perm="go-rwx" type="file">   <fileset dir="/web">       <include name="**/*.cgi"/>       <include name="**/*.old"/>    </fileset>    <dirset dir="/web">       <include name="**/private_*"/>    </dirset> </chmod>

    这个例子的作用是让不是文件的所有者可以访问cgi脚本。文件的权限将会改变的文件有:所有/web目录下的.cgi和.old文件,所有以private_*开头的文件或目录名以private_*开头的目录下的文件。

  • Copy Task : 把一个或者多个文件复制到指定的目录下

但要注意的是,如果目标目录下具有同名的文件,那么只有当源文件相对于目标文件更新时,Ant工具才会复制这个文件。在Copy任务中可以使用FileSet类型来定义文件集合。 

Copy Task的属性及功能  Copy 任务具有以下属性:  

(1)file:用于指定要复制的源文件。  

(2)preservelastmodified:作用是使得复制后的文件与源文件的最后修改时间相同。默认为false。  

(3)tofile:用于指定要复制到的文件。  

(4)todir:用于指定要复制到的目标目录。todir和tofile只能使用其中一个属性。 

(5)overwrite:用于指定是否需要覆盖目录和文件,不管文件是否比源文件新,都会覆盖。默认为false。 

(6)filtering:用于指定在复制时是否使用构件文件的全局过滤器对文件进行过滤。默认为false。

(7)flatten:用于指定是否需要复制目录,如果为true代表把所有的文件复制到todir属性设定的目录下。默认为false,复制目录。  

(8)includeEmptyDirs:用于指定是否复制空目录。默认为true。  

(9)failonerror:用于指定当遇到错误时是否停止执行。默认为true。 

(10)verbose:用于指定当复制文件时是否记录日志信息。  

(11)encoding:用于设定复制文件时的编码或文件过滤器使用的编码方式。默认时使用Java虚拟机的编码方式。  

(12)outputencoding:指定写文件时的编码方式。默认时使用Java虚拟机的编码方式。   (13)enablemultiplemappings:用于设定是否允许多个映射。默认为false。 

(14)granularity:用于指定一个文件修改时间的毫秒数据的允许误差。因为不是所有的文件系统的修改时间都是精确到毫秒数。默认时为0,如果为DOS系统则为2。

通过Copy Task实现文件和目录复制功能实例  

不管是对程序进行打包还是一般的文件操作,基本上都离不开复制功能。通过Ant工具的Copy任务可以让程序在Windows和Linux/UNIX下对文件和目录进行复制操作。
例如:  
(1)对单个文件进行复制:  

<copy file="myfile.txt" tofile="mycopy.txt"/>

这个例子的作用是在当前目录复制myfile.txt,并把复制的文件命名为mycopy.txt。当需要把文件复制到别外的目录时可以这样编写: 

 

    • <copy file="myfile.txt" todir="../some/other/dir"/>

      这个例子的作用是把文件复制到与当前目录同级的some目录的/other/dir子目录下。这里“..”代表相对路径(当前目录的上一级目录)。 

      (2)对文件目录进行复制: 

      <copy todir="../new/dir">     <fileset dir="src_dir"/>  </copy>

      这个例子的作用是把src_dir目录复制到../new/dir目录下。有时对文件进行复制时需要对文件进行备份。

      下面举一个复制文件时对文件进行备份的例子。 

      【ANT】Ant常用的内置task【ANT】Ant常用的内置task
      <copy todir="../backup/dir">    <fileset dir="src_dir">       <exclude name="**/*.java"/>    </fileset>    <globmapper from="*" to="*.bak"/> </copy>

      View Code  

      这个例子的作用是把src_dir目录及其子目录下所有非Java文件复制到../backup/dir目录下,并重命名为bak文件,以作备份。 

      在执行Copy Task时使用文件过滤的实例  

      下面是一个复制文件的同时替换文件中的特殊符号的例子:

      【ANT】Ant常用的内置task【ANT】Ant常用的内置task
      <copy todir="../backup/dir">     <fileset dir="src_dir"/>     <filterset>        <filter token="TITLE" value="Foo Bar"/>  </filterset> </copy>

      View Code

      这个例子的作用是把src_dir目录下的所有文件复制到../backup/dir目录,并在所有文件中查找并替换@TITLE@为Foo Bar。当要进行新产品发布时通过需要替换文件中的版本信息和时间信息。   说明:在Ant工具中还提供了copydir和copyfile这两个特定的任务,分别用于对目录和文件进行复制。但自从有了Copy任务后,这两个任务已过期,不建议再使用,应该统一使用Copy任务。

  • Echo Task : 输出系统信息

Echo任务的作用是根据logger(日志)或listener(**)的级别输出相应的信息。相当于Java中的System.out来输出信息。

Echo任务包含以下属性: 

(1)message:用于定义要输出的信息。这个属性是必需的。  

(2)file:用于定义一个文件。这个文件用于接收message定义的输出信息,当设定为把信息输出到接收文件时才起作用。  

(3)append:用于指定信息是否输出到指定的文件。默认为false。 

(4)level:用于指定这个信息的级别。可取值为error,warning,info,verbose或debug。   Echo任务的使用比较简单。例如定义一个信息的输出,代码如下:  

<echo message=" This is a simple message,out print by echo task! " />

当需要把信息输出到具体的文件中时,可以这样编写Echo Task:  

<echo message=" This is a simple message,out print by echo task! " file="/logs/messge.log" append="true"/>

      这个例子的作用是,把信息输出到/logs/message.log文件中,而不是直接输出到命令行。

  • Mkdir Task : 创建目录。

可用于Windows或Linux下建立目录。一个有趣的地方是,这个命令在Linux和Windows下相同,建立一个目录都可以通过Mkdir+目录名称来实现。Mkdir 任务只有一个属性dir,dir属性用于指定要创建的目录名称。可为相对路径也可以为绝对路径。   Mkdir的用法比较简单,例如在当前目录下创建一个名为dist的子目录(用于项目发布):  

<property name="dist" value="dist" /> <mkdir dir="${dist}"/>

虽然Mkdir任务相对简单,但Mkdir很有用,特别在创建文件前对目录进行验证。

 

  • Move Task : 移动文件或目录。

Move 任务用于移动文件和目录,默认时Move任务会覆盖目标文件或目录(如果目标文件或目录存在)。当关闭overwrite时,Move任务只会移动源文件比目标文件新的文件,或者目标文件不存在时才移动。在Move任务中可以引用FileSet类型。 

Move Task的属性及功能  Move 任务具有以下属性:  

(1)file:用于指定要移动的文件或目录。  

(2)preservelastmodified:用于指定移动后的文件的最后修改时间与源文件相同。 

(3)tofile:作用是指定移动后的文件新名称和位置。 

(4)todir:作用是指定文件目录的目标位置。

(5)overwrite:用于设定当源文件的最后修改时间大于目标文件的最后修改时间时,是否用源文件覆盖目标文件。默认为true。

(6)filtering:用于定义在移动时是否允许符号过滤。 

(7)flatten:作用是忽略目录结构。把各层目录下的文件移动到同一个目录下。默认为false。  

(8)includeEmptyDirs:用于指定在移动时是否忽略空目录。默认为false。 

(9)failonerror:用于定义当出现错误时是忽略并继续执行,还是当遇到错误时就停止执行命令。 

(10)verbose:用于指定当文件移动时是否输出日志信息。  

(11)encoding:用于定义在移动文件时使用的过滤器的编码方式。

(12)outputencoding:用于定义在写文件时使用的编码方式。 

 (13)enablemultiplemapping:用于指定是否可以使用多个映射。默认时只使用一个   映射。  

       (14)granularity:用于指定一个文件修改时间的毫秒数据的允许误差。因为不是所有的文件系统的修改时间都精确到毫秒数。默认时为0,如果是DOS系统则为2。  
        使用Move Task实现移动文件和目录功能的实例 

移动单个文件的实例:

<move file="file.orig" tofile="file.moved"/>

这个例子的作用是重命名file.org文件为file.moved。把文件移动到目录的例子如下:  

<move file="file.orig" todir="dir/to/move/to"/>  

这个例子的作用是把文件file.org移动到dir/to/move/to目录下。 

移动目录的实例: 

<move todir="new/dir/to/move/to">   <fileset dir="src/dir"/> </move>

这个例子的作用是把src/dir目录移动到new/dir/to/move/to目录。在Ant 1.6.3版本后,可以使用以下file属性来指定目录从而实现上面目录移动的功能:   <move file="src/dir" tofile="new/dir/to/move/to"/> 

通过Mapper功能对文件进行备份的例子: 

<move todir="my/src/dir" includeemptydirs="false">    <fileset dir="my/src/dir">       <exclude name="**/*.bak"/>    </fileset>    <mapper type="glob" from="*" to="*.bak"/> </move>

      这个实例的作用是把my/src/dir目录下的所有文件重命名为.bak的备份文件(.bak文件除外)。   

  • Zip Task : 创建ZIP文件。

在Zip任务里可以直接嵌套使用FileSet类型、include类型、exclude类型等,在这些文件类型中还可以对文件进行过滤。 

Zip任务具有以下属性,用于描述将要打包为zip的文件和目录等: 

(1)destfile:用于指定将要打包的zip文件。  

(2)zipfile:也用于指定要打包的zip文件,但已不建议使用,应该使用destfile属性来代替。zipfile属性和destfile属性两者必须选择其一。

 (3)basedir:用于指定打包zip文件的目录。 

 (4)compress:用于指定是否使用压缩的形式来保存数据。默认为true(对数据进行压缩)。  

(5)keepcompression:用于指定已压缩的zip文件保持原先的压缩格式。默认为false。   (6)encoding:用于指定Zip任务里的文件名称的编码方式。默认时采用操作系统的编码方式。 

 (7)filesonly:用于指定是否在Zip任务中只存储文件。默认为false。

 (8)includes:用于指定一个或多个在Zip任务中要包含的文件。可以使用逗号或空格符进行分隔。当这个属性被忽略时代表zip将包含所有文件。

 (9)includesfile:用于指定zip文件中要包含的文件的名称。

  (10)excludes:用于指定一个或多个在Zip任务中不被包含的文件。可以使用逗号或空格符进行分隔。当这个属性被忽略时代表Zip任务将包含所有文件。 

(11)excludesfile:用于指定在Zip任务中不被包含的文件的名称。 

 (12)defaultexcludes:用于定义是否在Zip中不包含Ant默认要排除的文件模式。可取值为yes或no。忽略时代表使用默认的排除文件模式,将不包含符合这些模式的文件。   (13)update:用于定义是否更新或覆盖目标文件,当目标文件已存在时。默认为false。   (14)whenempty:用于指定当没有满足打包条件的文件时的处理方式。可取值为fail、skip和create。fail代表创建zip失败,skip代表忽略不处理,create代表依然创建zip文件。默认为skip。 

(15)duplicate:定义当出现重复文件时的处理方式。可取值add、preserve和fail。add代表依然添加(覆盖)文件,preserve代表不打包重复文件,fail代表将打包失败。默认为add。  

(16)roundup:用于指定打包zip文件时文件的修改时间是否采用下一个连续的秒数。默认为true。 

(17)comment:作用是在zip文件中加上注释。

使用Zip Task打包zip文件的实例   在Zip任务中可以使用ZipFileSet类型定义一个或多个zip格式的文件集合,然后在Zip任务中引用。  

(1)      打包zip文件的实例,如下:

<zip destfile="${dist}/manual.zip" basedir="htdocs/manual" includes="api/**/*.html" excludes="**/todo.html" />

这个实例的作用是打包htdocs/manual目录下的文件,并且命名为manual.zip。在这个zip文件中只包含htdocs/manual/api目录或其子目录下的所有.html文件,但不包含其中文件名为todo.html的文件。  

以下是一个使用ant构建项目的完整的例子:

【ANT】Ant常用的内置task【ANT】Ant常用的内置task
<!-- 项目名称Cesium,默认targetcombine --><project name="Cesium" default="combine">  <!-- target名称build -->  <target name="build" description="A developer build that prepares the source tree for use as standard AMD modules.">    <!-- 新建文件夹任务${buildDirectory}" = ./build -->    <mkdir dir="${buildDirectory}" />    <!--自定义任务,把glsl转换为js -->    <glslToJavascript minify="${build.minification}" minifystatefile="${buildDirectory}/minifyShaders.state">      <!--glsl文件目录,${shadersDirectory}目录下的所有glsl文件 -->      <glslfiles dir="${shadersDirectory}" includes="**/*.glsl" />      <!--${shadersDirectory}目录下存在的js文件,不包括.profile.js -->      <existingjsfiles dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />    </glslToJavascript>    <!--自定义任务,创建CesiumJs,输出到${sourceDirectory}/Cesium.js -->    <createCesiumJs output="${sourceDirectory}/Cesium.js">      <!--源文件是以cesiumJsFiles为id的定义的fileset -->      <sourcefiles refid="cesiumJsFiles" />    </createCesiumJs>    <!--自定义任务,创建SpecList,输出到${specsDirectory}/SpecList.js -->    <createSpecList output="${specsDirectory}/SpecList.js">      <!--${specsDirectory}目录下所有js文件-->      <specs dir="${specsDirectory}" includes="**/*.js" excludes="*.js" />    </createSpecList>    <!--条件判断,如果${build.debugUnminified}的值为true,那么给exclude.development.gallery属性赋值为**/development/*.html-->    <condition property="exclude.development.gallery" value="**/development/*.html">      <istrue value="${build.debugUnminified}" />    </condition>    <!--自定义任务,创建GalleryList,输出到${galleryDirectory}/gallery-index.js -->    <createGalleryList output="${galleryDirectory}/gallery-index.js">      <!--根据上面的condition的条件,过滤掉值为${exclude.development.gallery}的文件 -->      <demos dir="${galleryDirectory}" includes="**/*.html" excludes="${exclude.development.gallery}" />    </createGalleryList>    <!--自定义任务,创建SandcastleJsHintOptions,输出到${sandcastleDirectory}/jsHintOptions.js -->    <createSandcastleJsHintOptions output="${sandcastleDirectory}/jsHintOptions.js" jshintoptionspath="${jsHintOptionsPath}" />  </target>  <!-- target名称combine,依赖于build、combineJavaScript,先顺序执行这两个target在执行combine target -->  <target name="combine" depends="build,combineJavaScript" description="Combines all source files into a single stand-alone script." />  <!--target名称minify -->  <target name="minify" description="Combines all source files into a single stand-alone, minified script.">    <!--调用combine target,并将参数build.minification和值true传进去 -->    <antcall target="combine">      <param name="build.minification" value="true" />    </antcall>    <!--调用minifyCSS target -->    <antcall target="minifyCSS" />  </target>  <!--target名称combineRelease -->  <target name="combineRelease" description="Combines all source files into a single stand-alone script with debugging code removed.">    <!--调用combine target,并将参数pragmas.debug和值false传进去 -->    <antcall target="combine">      <param name="pragmas.debug" value="false" />    </antcall>  </target>  <!--target名称minifyRelease -->  <target name="minifyRelease" description="Combines all source files into a single stand-alone, minified script with debugging code removed.">    <!--调用minify target,并将参数传进去 -->    <antcall target="minify">      <param name="pragmas.debug" value="false" />    </antcall>  </target>  <!--target名称release -->  <target name="release" description="A full release build that creates a shippable product, including building apps and generating documentation.">    <!--调用minifyRelease target -->    <antcall target="minifyRelease" />    <!--调用combine target,并传参 -->    <antcall target="combine">      <param name="build.debugUnminified" value="true" />    </antcall>    <!--调用generateDocumentation target -->    <antcall target="generateDocumentation" />    <!--调用buildApps target -->    <antcall target="buildApps" />  </target>  <!--target名称instrumentForCoverage,依赖于build target -->  <target name="instrumentForCoverage" depends="build" description="A debug build instrumented for JSCoverage (currently Windows only).">    <!--执行命令${jscoveragePath},参数为 ${sourceDirectory} ${instrumentedDirectory} -no-instrument=./ThirdParty-->    <exec executable="${jscoveragePath}">      <arg value="${sourceDirectory}" />      <arg value="${instrumentedDirectory}" />      <arg value="--no-instrument=./ThirdParty" />    </exec>  </target>  <!--target名称makeZipFile,依赖于release target -->  <target name="makeZipFile" depends="release" description="Builds zip files containing all release files.">    <!--执行内置系统任务zip,输出到Cesium-${version}.zip,以${basedir}为基准路径 -->    <zip destfile="Cesium-${version}.zip" basedir="${basedir}">      <!--定义了所有要打包的文件目录及文件和排除的文件 -->      <zipfileset dir="${buildDirectory}" prefix="Build">        <include name="Apps/**" />        <exclude name="Apps/TimelineDemo/**" />        <include name="Cesium/**" />        <include name="CesiumUnminified/**" />        <include name="Documentation/**" />      </zipfileset>      <include name="Apps/**" />      <exclude name="Apps/Sandcastle/gallery/development/**" />      <include name="Source/**" />      <include name="Specs/**" />      <include name="ThirdParty/**" />      <include name="logo.png" />      <include name="favicon.ico" />      <include name="server.js" />      <include name="package.json" />      <include name="LICENSE.md" />      <include name="CHANGES.md" />      <include name="README.md" />      <include name="web.config" />      <zipfileset file="index.release.html" fullpath="index.html" />    </zip>  </target>  <!--target名称clean -->  <target name="clean" description="Removes all generated build artifacts.">    <!--删除文件任务,包含空目录,遇到错误不停止任务,并定义了要删除的文件集合fileset -->    <delete includeEmptyDirs="true" failonerror="false">      <fileset dir="${sourceDirectory}" includes="Cesium.js" />      <fileset dir="${buildDirectory}" defaultexcludes="false" />      <fileset dir="${instrumentedDirectory}" defaultexcludes="false" />      <fileset dir="${shadersDirectory}" includes="**/*.js" excludes="*.profile.js" />      <fileset dir="${specsDirectory}" includes="SpecList.js" />      <fileset dir="${sandcastleDirectory}" includes="jsHintOptions.js" />      <fileset dir="${galleryDirectory}" includes="gallery-index.js" />      <fileset dir="." includes="Cesium-*.zip" />    </delete>  </target>  <!-- 定义全局属性,引用方式如:${build.minification},即false -->  <property name="build.minification" value="false" />  <property name="pragmas.debug" value="true" />  <property name="runServer.public" value="false" />  <property name="runServer.port" value="8080" />  <property name="version" value="1.13" />  <property name="sourceDirectory" location="Source" />  <property name="shadersDirectory" location="${sourceDirectory}/Shaders" />  <property name="examplesDirectory" location="Examples" />  <property name="sandcastleDirectory" location="Apps/Sandcastle" />  <property name="galleryDirectory" location="${sandcastleDirectory}/gallery" />  <property name="specsDirectory" location="Specs" />  <property name="toolsDirectory" location="Tools" />  <property name="tasksDirectory" location="${toolsDirectory}/buildTasks" />  <property name="thirdPartyDirectory" location="ThirdParty" />  <property name="requirejsPath" location="${thirdPartyDirectory}/requirejs-2.1.9" />  <property name="rjsPath" location="${requirejsPath}/r.js" />  <property name="rjsOptions" location="${toolsDirectory}/build.js" />  <property name="almondPath" location="${thirdPartyDirectory}/almond-0.2.6/almond.js" />  <property name="jscoveragePath" location="${toolsDirectory}/jscoverage-0.5.1/jscoverage.exe" />  <property name="rhinoJarPath" location="${toolsDirectory}/rhino-1.7R4/js.jar" />  <property name="documentationImagesDirectory" location="Documentation/Images" />  <property name="jsdoc3Directory" location="${toolsDirectory}/jsdoc3" />  <property name="webProxyDirectory" location="${toolsDirectory}/proxy" />  <property name="jsHintPath" location="${thirdPartyDirectory}/jshint-2.1.10/jshint.js" />  <property name="clocPath" location="${toolsDirectory}/cloc-1.60/cloc-1.60.pl" />  <property name="clocDefinitionsPath" location="${toolsDirectory}/cloc-1.60/cloc_definitions" />  <property name="jsHintOptionsPath" location=".jshintrc" />  <property name="nodePath" value="node" />  <property name="npmPath" value="npm" />  <!-- Outputs -->  <property name="buildDirectory" location="Build" />  <property name="buildOutputDirectory" location="${buildDirectory}/Cesium" />  <property name="unminifiedOutputDirectory" location="${buildDirectory}/CesiumUnminified" />  <property name="buildDocumentationDirectory" location="${buildDirectory}/Documentation" />  <property name="buildDocumentationImagesDirectory" location="${buildDocumentationDirectory}/images" />  <property name="instrumentedDirectory" location="Instrumented" />  <property name="buildStubsDirectory" location="${buildDirectory}/Stubs" />  <!-- 声明一组路径,并以相应的系统分隔符来分割,并命名id为javascriptClassPath,在后面用refid引用该路径-->  <path id="javascriptClassPath">    <pathelement path="${rhinoJarPath}" />    <pathelement path="${toolsDirectory}/bsf-2.4.0/bsf.jar" />    <pathelement path="${toolsDirectory}/commons-logging-1.1.1/commons-logging-1.1.1.jar" />  </path>  <!-- 定义一组文件-->  <union id="cesiumJsFiles">    <fileset dir="${sourceDirectory}">      <include name="**/*.js" />      <exclude name="*.js" />      <exclude name="Workers/**" />      <exclude name="ThirdParty/Workers/**" />      <exclude name="**/*.profile.js" />    </fileset>    <fileset dir="${sourceDirectory}">      <include name="Workers/createTaskProcessorWorker.js" />    </fileset>  </union>  <!-- 定义一组文件-->  <fileset dir="${sourceDirectory}" id="cesiumWorkersJsFileSet">    <include name="**/*.js" />    <exclude name="*.js" />    <exclude name="**/*.profile.js" />  </fileset>  <!-- 声明自定义任务glslToJavascript,语言为javascript,处理该任务的源文件是${tasksDirectory}/glslToJavaScript.js,使用manager作为引擎,引用之前定义的类路径javascriptClassPath作为classpath -->  <!-- 该任务的使用见target build-->  <scriptdef name="glslToJavascript" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/glslToJavaScript.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="minify" />    <attribute name="minifystatefile" />    <element name="glslfiles" type="fileset" />    <element name="existingjsfiles" type="fileset" />  </scriptdef>  <scriptdef name="createCesiumJs" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/createCesiumJs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="output" />    <element name="sourcefiles" type="resources" />  </scriptdef>  <scriptdef name="createSpecList" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/createSpecList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="output" />    <element name="specs" type="fileset" />  </scriptdef>  <scriptdef name="createGalleryList" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/createGalleryList.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="output" />    <element name="demos" type="fileset" />  </scriptdef>  <scriptdef name="createSandcastleJsHintOptions" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/createSandcastleJsHintOptions.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="output" />    <attribute name="jshintoptionspath" />  </scriptdef>  <scriptdef name="runJsHint" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/runJsHint.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="jshintpath" />    <attribute name="jshintoptionspath" />    <attribute name="sandcastlejshintoptionspath" />    <attribute name="failureproperty" />    <element name="sourcefiles" type="fileset" />  </scriptdef>  <scriptdef name="generateStubs" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/generateStubs.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <attribute name="stuboutput" />    <attribute name="pathsoutput" />    <element name="sourcefiles" type="resources" />  </scriptdef>  <scriptdef name="sortRequires" language="javascript" src='/images/loading.gif' data-original="${tasksDirectory}/sortRequires.js" manager="bsf" classpathref="javascriptClassPath" loaderref="javascript.loader">    <element name="sourcefiles" type="fileset" />  </scriptdef>  <!-- target名称jsHint(js语法检查),依赖于buildtarget-->  <target name="jsHint" depends="build" description="Runs JSHint on the entire source tree.">    <!-- 运行自定义任务runJsHint,由前面的scriptdef声明的,并给参数传值(指定jsHint路径、options路径、sandcastlejshintoptions路径)、源文件等-->    <runJsHint jshintpath="${jsHintPath}" jshintoptionspath="${jsHintOptionsPath}" sandcastlejshintoptionspath="${sandcastleDirectory}/jsHintOptions.js" failureproperty="jsHint.failure">      <sourcefiles dir="${basedir}">        <include name="Source/**/*.js" />        <exclude name="Source/Shaders/**" />        <exclude name="Source/ThirdParty/**" />        <exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />        <include name="Apps/**/*.js" />        <include name="Apps/Sandcastle/gallery/*.html" />        <exclude name="Apps/Sandcastle/ThirdParty/**" />        <include name="Specs/**/*.js" />        <include name="Tools/buildTasks/**/*.js" />      </sourcefiles>    </runJsHint>    <fail if="jsHint.failure" message="JSHint failed!" />  </target>  <!-- target名称sortRequires-->  <target name="sortRequires" description="Sorts the list of requires in all source files">    <!-- 执行自定义任务sortRequires,并给元素sourecesfiles传值(指定源文件)-->    <sortRequires>      <sourcefiles dir="${basedir}">        <include name="Source/**/*.js" />        <exclude name="Source/Shaders/**" />        <exclude name="Source/ThirdParty/**" />        <exclude name="Source/Workers/cesiumWorkerBootstrapper.js" />        <exclude name="Source/copyrightHeader.js" />        <exclude name="Source/Workers/transferTypedArrayTest.js" />        <include name="Apps/**/*.js" />        <exclude name="Apps/Sandcastle/ThirdParty/**" />        <include name="Specs/**/*.js" />        <exclude name="Specs/SpecRunner.js" />        <exclude name="Specs/SpecList.js" />        <exclude name="Apps/Sandcastle/Sandcastle-client.js" />        <exclude name="Apps/Sandcastle/Sandcastle-header.js" />        <exclude name="Apps/Sandcastle/Sandcastle-warn.js" />        <exclude name="Apps/Sandcastle/gallery/gallery-index.js" />        <exclude name="Apps/Sandcastle/jsHintOptions.js" />        <exclude name="**/*.profile.js" />      </sourcefiles>    </sortRequires>  </target>  <target name="cloc" depends="build" description="Runs cloc to count lines of code for Source and Specs directories.">    <echo message="Source:" />    <apply executable="perl" parallel="true">      <arg value="${clocPath}" />      <arg value="--quiet" />      <arg value="--progress-rate=0" />      <arg value="--read-lang-def=${clocDefinitionsPath}" />      <arg value="Source/Core/" />      <arg value="Source/DataSources/" />      <arg value="Source/Renderer/" />      <arg value="Source/Scene/" />      <arg value="Source/Widgets/" />      <arg value="Source/Workers/" />      <fileset id="clocFileSet" dir="Source/">        <include name="Shaders/*.glsl" />        <include name="Shaders/**/*.glsl" />        <include name="main.js" />      </fileset>    </apply>    <echo message="${line.separator}Specs:" />    <exec executable="perl">      <arg value="${clocPath}" />      <arg value="--quiet" />      <arg value="--progress-rate=0" />      <arg value="--read-lang-def=${clocDefinitionsPath}" />      <arg value="Specs/" />    </exec>  </target>  <!-- target名称checkForNode,nodejs环境检查-->  <target name="checkForNode">    <!-- 执行node任务 node -version -->    <exec executable="${nodePath}" failonerror="false" failifexecutionfails="false" resultproperty="node.exec.result">      <arg value="--version" />    </exec>    <fail message="Node.js is required to run this part of the build. Install from http://nodejs.org/">      <condition>        <not>          <equals arg1="${node.exec.result}" arg2="0" />        </not>      </condition>    </fail>  </target>  <!-- 任务名称combineJavaScript.create,合并所有js源文件 -->  <target name="combineJavaScript.create">    <!-- 设置相对路径属性,因为r.js不能处理windows的绝对路径 -->    <property name="relativeAlmondPath" location="${almondPath}" relative="true" basedir="${sourceDirectory}" />    <property name="combineOutputDirectory" location="${buildDirectory}/combineOutput" />    <!-- 创建合并的js存放目录 -->    <mkdir dir="${combineOutputDirectory}" />    <property name="relativeCombineOutputDirectory" location="${combineOutputDirectory}" relative="true" basedir="${sourceDirectory}" />    <!-- 调用combineJavaScript.combineCesium target,创建合并的js源文件  -->    <antcall target="combineJavaScript.combineCesium" />    <!--调用自定义任务generateStubs,生成stubs,指定生成路径,和所需源文件等参数   -->    <mkdir dir="${buildStubsDirectory}" />    <generateStubs stuboutput="${buildStubsDirectory}/Cesium.js" pathsoutput="${buildStubsDirectory}/paths.js">      <sourcefiles refid="cesiumJsFiles" />    </generateStubs>    <!-- 调用combineJavaScript.combineCesiumWorkers target,合并所有web workers,因为web worker 源文件需要单独处理,不能和其他js文件合并在一起 -->    <antcall target="combineJavaScript.combineCesiumWorkers" />    <!-- 将合并的文件复制到相应目录下,并在文件头添加copyrightHeader.js文件的内容 -->    <copy todir="${outputDirectory}">      <fileset dir="${combineOutputDirectory}" />      <filterchain>        <concatfilter prepend="${sourceDirectory}/copyrightHeader.js" />      </filterchain>    </copy>    <!-- 删除中间文件夹${combineOutputDirectory} -->    <delete dir="${combineOutputDirectory}" />    <!-- 复制其他资源(css、texture等)到${outputDirectory},不包括空文件夹和glsl。json等文件 -->    <copy todir="${outputDirectory}" includeEmptyDirs="false">      <fileset dir="${sourceDirectory}">        <exclude name="**/*.js" />        <exclude name="**/*.glsl" />        <exclude name="**/.gitignore" />        <exclude name="**/package.json" />      </fileset>    </copy>  </target>  <!-- 合并js源文件target -->  <target name="combineJavaScript.combineCesium" depends="combineJavaScript.combineCesium.check" unless="no.combineCesium.create">    <!-- 执行node r.js -o optiongs.......(模块包裹wrap=true,css优化方式:标准压缩,js文件优化方式:不压缩代码,skipModuleInsertion避免不是用define来定义模块但是又用r.js来压缩代码产生的bug,压缩main.js的模块及其依赖项,输出到out指定目录) -->    <exec executable="${nodePath}" dir="${sourceDirectory}">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <arg value="pragmas.debug=${pragmas.debug}" />      <arg value="optimize=${optimize}" />      <arg value="baseUrl=." />      <arg value="skipModuleInsertion=true" />      <arg value="name=${relativeAlmondPath}" />      <arg value="include=main" />      <arg value="out=${relativeCombineOutputDirectory}/Cesium.js" />    </exec>  </target>  <!-- 合并webwork源文件target -->  <target name="combineJavaScript.combineCesiumWorkers" depends="combineJavaScript.combineCesiumWorkers.check" unless="no.combineCesiumWorkers.create">    <!-- 创建独立的web worker文件node r.js -o............ -->    <apply executable="${nodePath}" dir="${sourceDirectory}" relative="true" force="true">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <arg value="pragmas.debug=${pragmas.debug}" />      <arg value="optimize=${optimize}" />      <arg value="baseUrl=." />      <arg value="skipModuleInsertion=true" />      <arg value="wrap=false" />      <srcfile prefix="include=" />      <targetfile prefix="out=" />      <globmapper from="*" to="${relativeCombineOutputDirectory}/*.js" />      <mappedresources>        <fileset dir="${sourceDirectory}">          <include name="Workers/cesiumWorkerBootstrapper.js" />          <include name="Workers/transferTypedArrayTest.js" />          <include name="ThirdParty/Workers/*.js" />        </fileset>        <chainedmapper>          <globmapper from="*.js" to="*" />        </chainedmapper>      </mappedresources>    </apply>    <!-- 创建合并的worker文件 -->    <apply executable="${nodePath}" dir="${sourceDirectory}" relative="true" force="true">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <arg value="optimize=${optimize}" />      <arg value="pragmas.debug=${pragmas.debug}" />      <arg value="baseUrl=." />      <srcfile prefix="name=Workers/" />      <targetfile prefix="out=" />      <globmapper from="*" to="${relativeCombineOutputDirectory}/Workers/*.js" />      <mappedresources>        <fileset dir="${sourceDirectory}/Workers">          <include name="*.js" />          <exclude name="*.profile.js" />          <exclude name="cesiumWorkerBootstrapper.js" />          <exclude name="transferTypedArrayTest.js" />          <exclude name="createTaskProcessorWorker.js" />        </fileset>        <chainedmapper>          <flattenmapper />          <globmapper from="*.js" to="*" />        </chainedmapper>      </mappedresources>    </apply>  </target>  <!-- 合并js文件前的检查,如果指定的目标文件${outputDirectory}/Cesium.js与源文件cesiumJsFiles的引用文件集相比有更新的时间错,则设置属性no.combineCesium.create-->  <target name="combineJavaScript.combineCesium.check">    <uptodate property="no.combineCesium.create" targetfile="${outputDirectory}/Cesium.js">      <srcresources refid="cesiumJsFiles" />    </uptodate>  </target>  <target name="combineJavaScript.combineCesiumWorkers.check">    <uptodate property="no.combineCesiumWorkers.create" targetfile="${outputDirectory}/Cesium.js">      <srcfiles refid="cesiumWorkersJsFileSet" />    </uptodate>  </target>  <!-- 合并js源文件,并且不压缩代码target-->  <target name="combineJavaScript.createUnminified">    <antcall target="combineJavaScript.create">      <param name="optimize" value="none" />      <param name="outputDirectory" value="${unminifiedOutputDirectory}" />    </antcall>  </target>  <!-- copy的条件:${build.minification}为true并且设置了build.debugUnminified,就设置属性combineJavascript.noCopy-->  <target name="combineJavascript.checkCopy">    <condition property="combineJavascript.noCopy">      <or>        <istrue value="${build.minification}" />        <isset property="build.debugUnminified" />      </or>    </condition>  </target>  <!-- 复制合并的js文件,依赖于copy检查target-->  <target name="combineJavaScript.copyUnminified" depends="combineJavascript.checkCopy" unless="${combineJavascript.noCopy}">    <copy todir="${buildOutputDirectory}">      <fileset dir="${unminifiedOutputDirectory}" />    </copy>  </target>  <!-- 合并js文件并且压缩代码,条件是${build.minification}为ture-->  <target name="combineJavaScript.createMinified" if="${build.minification}">    <!-- 调用combineJavaScript.create,传入参数uglify2(使用uglify2压缩代码),输出目录${buildOutputDirectory}-->    <antcall target="combineJavaScript.create">      <param name="optimize" value="uglify2" />      <param name="outputDirectory" value="${buildOutputDirectory}" />    </antcall>  </target>  <!-- 合并js文件,依赖于node环境检查、创建没有压缩的js代码,复制合并代码等target-->  <target name="combineJavaScript" depends="checkForNode,combineJavaScript.createUnminified,combineJavaScript.copyUnminified,combineJavaScript.createMinified" />  <!-- 压缩CSS。依赖于nodejs环境检查-->  <target name="minifyCSS" depends="checkForNode">    <!-- copy任务:复制${sourceDirectory}目录下的css到${buildOutputDirectory}目录下,不包括空文件夹,如果存在则覆盖-->    <copy todir="${buildOutputDirectory}" includeEmptyDirs="false" overwrite="true">      <fileset dir="${sourceDirectory}">        <include name="**/*.css" />      </fileset>    </copy>    <!-- 压缩任务:node r.js -o....-->    <apply executable="${nodePath}" dir="${buildOutputDirectory}" relative="true">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <srcfile prefix="cssIn=" />      <targetfile prefix="out=" />      <identitymapper />      <fileset dir="${buildOutputDirectory}">        <include name="**/*.css" />      </fileset>    </apply>  </target>  <!-- 操作系统检查:如果系统是windows,则设置属性os.windows-->  <condition property="os.windows">    <os family="windows" />  </condition>  <!-- 如果系统不是windows,执行的npmInstall任务-->  <target name="npmInstall.nonWindows" unless="os.windows">    <!-- npm install(依赖于package.json)-->    <exec executable="${npmPath}" dir="${basedir}" failonerror="true">      <arg value="install" />    </exec>  </target>  <!-- 如果系统是windows,执行的npmInstall-->  <target name="npmInstall.windows" if="os.windows">    <!-- /c npm install-->    <exec executable="cmd" dir="${basedir}" failonerror="true">      <arg value="/c" />      <arg value="${npmPath}" />      <arg value="install" />    </exec>  </target>  <!-- npmInstall 依赖于系统检查-->  <target name="npmInstall" depends="npmInstall.windows,npmInstall.nonWindows" />  <!-- 生成文档,依赖于npminstall-->  <target name="generateDocumentation" depends="checkForNode,npmInstall" description="Generates HTML documentation.">    <!-- 执行命令:node node_modules/jsdoc/jsdoc.js conf....-->    <exec executable="${nodePath}" dir="${basedir}" failonerror="true">      <env key="CESIUM_VERSION" value="${version}" />      <arg value="node_modules/jsdoc/jsdoc.js" />      <arg line="--configure Tools/jsdoc/conf.json" />    </exec>    <!-- copy任务:把${documentationImagesDirectory}目录复制到${buildDocumentationImagesDirectory}目录-->    <copy todir="${buildDocumentationImagesDirectory}">      <fileset dir="${documentationImagesDirectory}" />    </copy>  </target>  <!-- 运行server,依赖于nodejs环境检查,npminstall等target-->  <target name="runServer" depends="checkForNode,npmInstall" description="Runs a local web server.">    <echo>The local web server can also be launched directly by running: node server.js</echo>    <!-- 条件判断:${runServer.public}为true,泽设置属性runServer.arg.public值为public -->    <condition property="runServer.arg.public" value="--public" else="">      <istrue value="${runServer.public}" />    </condition>    <!-- 执行命令启动server:node server.js ${runServer.arg.public} port ${runServer.port} -->    <exec executable="${nodePath}" dir="${basedir}" failonerror="true">      <arg value="server.js" />      <arg line="${runServer.arg.public}" />      <arg line="--port ${runServer.port}" />    </exec>  </target>  <!-- 启动server,public为true -->  <target name="runPublicServer" description="Runs a public web server.">    <antcall target="runServer">      <param name="runServer.public" value="true" />    </antcall>  </target>  <!-- 创建APPs,调用buildCesiumViewer target -->  <target name="buildApps" description="Create built versions of all example applications.">    <antcall target="buildCesiumViewer" />  </target>  <!-- 创建cesiemviewer 依赖于nodejs环境检查 -->  <target name="buildCesiumViewer" depends="checkForNode">    <!-- 设置路径属性 -->    <property name="cesiumViewerDirectory" location="Apps/CesiumViewer" />    <property name="cesiumViewerOutputDirectory" location="${buildDirectory}/Apps/CesiumViewer" />    <mkdir dir="${cesiumViewerOutputDirectory}" />    <property name="relativeCesiumViewerOutputDirectory" location="${cesiumViewerOutputDirectory}" relative="true" basedir="${cesiumViewerDirectory}" />    <!-- 压缩js代码,生成${relativeCesiumViewerOutputDirectory}/CesiumViewerStartup.js -->    <exec executable="${nodePath}" dir="${cesiumViewerDirectory}">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <arg value="optimize=uglify2" />      <arg value="pragmas.debug=false" />      <arg value="mainConfigFile=../Apps/CesiumViewer/CesiumViewerStartup.js" />      <arg value="name=CesiumViewerStartup" />      <arg value="out=${relativeCesiumViewerOutputDirectory}/CesiumViewerStartup.js" />    </exec>    <!-- 将copyright头添加到CesiumViewerStartup.js -->    <copy file="${cesiumViewerOutputDirectory}/CesiumViewerStartup.js" tofile="${cesiumViewerOutputDirectory}/CesiumViewerStartup.js.tmp">      <filterchain>        <concatfilter prepend="${sourceDirectory}/copyrightHeader.js" />      </filterchain>    </copy>    <!-- 重命名 -->    <move file="${cesiumViewerOutputDirectory}/CesiumViewerStartup.js.tmp" tofile="${cesiumViewerOutputDirectory}/CesiumViewerStartup.js" />    <!-- 压缩CSS -->    <exec executable="${nodePath}" dir="${cesiumViewerDirectory}">      <arg value="${rjsPath}" />      <arg value="-o" />      <arg value="${rjsOptions}" />      <arg value="cssIn=CesiumViewer.css" />      <arg value="out=${relativeCesiumViewerOutputDirectory}/CesiumViewer.css" />    </exec>    <!-- 复制${cesiumViewerDirectory}目录下的其他资源,图片、html等 到${cesiumViewerOutputDirectory}目录下-->    <copy todir="${cesiumViewerOutputDirectory}">      <fileset dir="${cesiumViewerDirectory}">        <exclude name="*.js" />        <exclude name="*.css" />      </fileset>    </copy>    <!-- 复制requirejs -->    <copy file="${requirejsPath}/require.min.js" tofile="${cesiumViewerOutputDirectory}/require.js" />    <!-- 复制assets、webworker文件、css等到 ${cesiumViewerOutputDirectory}-->    <copy todir="${cesiumViewerOutputDirectory}" includeemptydirs="false">      <fileset dir="${buildOutputDirectory}">        <include name="Assets/**" />        <include name="Workers/**" />        <include name="ThirdParty/Workers/**" />        <include name="Widgets/**" />        <exclude name="Widgets/**/*.css" />      </fileset>      <fileset dir="${buildOutputDirectory}">        <include name="Widgets/InfoBox/InfoBoxDescription.css" />      </fileset>    </copy>    <!-- 复制webconfig -->    <copy file="${basedir}/web.config" tofile="${cesiumViewerOutputDirectory}/web.config" />    <!-- 字符替换:把${cesiumViewerOutputDirectory}下的CesiumViewerStartup.js所有../../Source和../../ThirdParty/requirejs-2.1.9替换为. -->    <replace dir="${cesiumViewerOutputDirectory}" summary="true">      <replacefilter token="../../Source" value="." />      <replacefilter token="../../ThirdParty/requirejs-2.1.9" value="." />      <include name="CesiumViewerStartup.js" />    </replace>    <!-- 字符替换(html引用的路径): ${cesiumViewerOutputDirectory}下的index.html的../../ThirdParty/requirejs-2.1.9替换为.-->    <replace dir="${cesiumViewerOutputDirectory}" summary="true">      <replacefilter token="../../ThirdParty/requirejs-2.1.9" value="." />      <include name="index.html" />    </replace>    <!-- 字符替换(css路径): ${cesiumViewerOutputDirectory}下的所有css文件的../../Source/替换为空-->    <replace dir="${cesiumViewerOutputDirectory}" summary="true">      <replacefilter token="../../Source/" value="" />      <include name="*.css" />    </replace>  </target></project>

View Code

 

 




原标题:【ANT】Ant常用的内置task

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

国际物流哪个好:https://www.goluckyvip.com/tag/101279.html
网站建:https://www.goluckyvip.com/tag/10128.html
富莱国际物流:https://www.goluckyvip.com/tag/101280.html
丰达国际物流:https://www.goluckyvip.com/tag/101281.html
中欧国际货运:https://www.goluckyvip.com/tag/101282.html
飞龙国际物流:https://www.goluckyvip.com/tag/101283.html
在古巴做游轮 古巴旅游项目:https://www.vstour.cn/a/363194.html
西藏旅游攻略自驾游需要多少天 去西藏旅游自驾游要多久时间:https://www.vstour.cn/a/363195.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流