alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (untar.xml)

This example Ant source code file (untar.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

The untar.xml source code

<?xml version="1.0"?>

<project basedir="." default="cleanup">

  <target name="cleanup">
    <delete file="asf-logo.gif" />
    <delete file="untartest.tar" />
    <delete dir="untartestin"/>
    <delete dir="untartestout"/>
  </target>

  <target name="testTarTask">
    <ant antfile="tar.xml" target="feather" />
    <untar src="asf-logo.gif.tar" dest="." />
    <ant antfile="tar.xml" target="cleanup" />
  </target>

  <target name="testGzipTarTask">
    <ant antfile="tar.xml" target="feather" />
    <untar src="asf-logo.gif.tar.gz" dest="." compression="gzip" />
    <ant antfile="tar.xml" target="cleanup" />
  </target>

  <target name="testBzip2TarTask">
    <ant antfile="tar.xml" target="feather" />
    <untar src="asf-logo.gif.tar.bz2" dest="." compression="bzip2"/>
    <ant antfile="tar.xml" target="cleanup" />
  </target>

  <target name="realTest">
    <untar src="expected/asf-logo.gif.tar" dest="." />
  </target>

  <target name="realGzipTest">
    <untar src="expected/asf-logo.gif.tar.gz" dest="." compression="gzip" />
  </target>

  <target name="realBzip2Test">
    <untar src="expected/asf-logo.gif.tar.bz2" dest="." compression="bzip2"/>
  </target>


  <target name="srcDirTest">
    <untar src="." dest="." />
  </target>

  <target name="encoding">
    <untar src="expected/asf-logo.gif.tar" dest="." encoding="foo"/>
  </target>

  <target name="resourceCollection">
    <mkdir dir="untartestout"/>
    <zip destfile="untartestout/test.zip">
      <fileset dir="expected">
        <include name="asf-logo.gif.tar"/>
      </fileset>
    </zip>
    <untar dest=".">
      <zipfileset src="untartestout/test.zip">
        <include name="*.tar"/>
      </zipfileset>
    </untar>
  </target>

  <target name="prepareTestTar">
    <mkdir dir="untartestin/1"/>
    <mkdir dir="untartestin/2"/>
    <touch file="untartestin/1/foo"/>
    <touch file="untartestin/2/bar"/>
    <copy todir="untartestin/2">
      <fileset dir="expected" includes="*md5*"/>
    </copy>
    <tar destfile="untartest.tar" basedir="untartestin"/>
  </target>

  <target name="testDocumentationClaimsOnCopy" depends="prepareTestTar">
    <copy todir="untartestout" preservelastmodified="true"> 
      <tarfileset src="untartest.tar">
        <patternset>
          <include name="2/"/>
        </patternset>
      </tarfileset>
    </copy>
  </target>
  
</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant untar.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.