Compress everything


<project basedir="." default="build" name="myProjectName">
  <tstamp><format property="DAY_TIME_NOW" pattern="" /></tstamp>
    Will compress everything into myProjectName_YYYY-MM-DD_HH.MM.SS.tar.gz,
      except files with the format myProjectName_*.tar.gz and db directory.
  <target name="pack_code" description="Packing everything.">
    <tar compression="gzip" destfile="${}_${DAY_TIME_NOW}.tar.gz" 
      excludes="db/**, **/${}_*.tar.gz"  
  <!-- Or compress multiple specific files. -->
  <target name="compress_multiple_files">
    <tar compression="gzip" destfile="/path/to/my_archive.tar.gz">
      <tarfileset dir=".">
        <include name="my_file1.txt"/>
        <include name="my_file2.txt"/>

Note: Don't use base="." attribute in <tar> if the base directory have a directory that contains a lot of files(>50 000). Otherwise, it will be very slow, even you are not compressing that huge directory.