Recently, I was working on a Huawei Product Line website. Since each publication needs to be packaged and deployed once, the leader asked me to pack only the upgrade package each time. This requires me to write a script to pack the upgrade package, so I thought of using ant. The specific implementation idea is as follows: during each package, the files modified after the last packaging time are retrieved and packaged. This is fast and convenient. The specific steps are as follows: first, ant installation and configuration ant: http://ant.apache.org download ant and unzip, then add ant system variable: ant_home, pointing to the path after ant decompression, add the ant bin path to the system environment variable path. After the ant environment is configured, the following is the ant XML file:
<? XML version = "1.0"?>
<Project name = "openlab">
<! -- Openlab source file path -->
<Property name = "sourcedir" value = "../openlab/webroot"/>
<! -- Openlab package path -->
<Property name = "targetdir" value = "$ {basedir} \ openlab"/>
<! -- Last packaging date -->
<Property name = "modifydate" value = "19/01/2012"/>
<! -- Packaging date -->
<Property name = "today" value = "2012_02_02"/>
<! -- Create path -->
<Target name = "init">
<Mkdir dir = "targetdir"/>
</Target>
<! -- Copy the updated file to the target path -->
<Target name = "copyopenlab" depends = "clean">
<Copy todir = "$ {targetdir}" includeemptydirs = "false" Overwrite = "true">
<Fileset dir = "$ {sourcedir}">
<Date pattern = "DD/MM/YYYY" datetime = "$ {modifydate}" When = "after"/>
</Fileset>
</Copy>
</Target>
<! -- Delete previous versions -->
<Target name = "clean">
<Delete dir = "openlab"/>
<Delete>
<Fileset dir = "." supported des = "*. Zip"/>
</Delete>
</Target>
<! -- Package -->
<Target name = "zipopenlab" depends = "init, copyopenlab">
<Zip destfile = "$ {basedir}/openlab_${today).zip" des = "openlab/**" basedir = "$ {basedir}">
</Zip>
</Target>
</Project>
Finally, write a batch processing file openlab. BAT: @ echo openlab package ant zipopenlab. In this way, you only need to modify the date of the last package and then double-click the batch processing file.