Ant application-engineering upgrade package

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.