Use File compression in ant

Source: Internet
Author: User
<? XML version = "1.0"?>

<Project name = "access" default = "show" basedir = ".">
<Buildnumber/>

<Target name = "show">
<Echo message = "$ {build. Number}"/>
<Tar destfile = "commandid build.number#.tar.bz2" compression = "Bzip2">
<Fileset dir = ".">
<Include name = "*. xml"/>
</Fileset>
</Tar>

<Untar src = "commandid build.number#.tar.bz2" compression = "Bzip2" DEST = "DEST"/>
</Target>
</Project>

Buildnumber: ant adds the value and writes it to a build. number (under basedir ). of course, you can also use the File Attribute to specify a file. as follows:

<Buildnumber file = "My. properties"/>

If the build. number value cannot be found in the specified (or default) file by ANT during runtime, it will generate the value again and increase from 0.

 

Tar is a packaging command on Linux. in Linux, File compression commands such as ZIP, Gzip, and Bzip2 can only be used for separate files. You cannot compress files or multiple files. to make multiple files form a whole, you need to use the tar command. tar connects multiple scattered files into a whole, but by default, it does not compress these scattered files. That is to say, the tar command is generated to form an overall file (a real packaging command), and then used for File compression commands such as gzip and Bzip2. In the subsequent development of tar, for convenience, tar has some attribute options for File compression. Ant's tar command imitates the tar command on Linux. You can add a compression attribute to compress the file. The specific package and package are as follows.

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.