tags:

views:

670

answers:

2

I'm using Ant 1.7.1 to tar up the contents of a directory, that contains a .git subdirectory. My current task is

<tar
    destfile="sali-src-${version}.tgz"
    basedir="${basedir}"
    compression="gzip"
    excludes=".git, .gitignore, *.ipr, *.iws, *.iml">
</tar>

But the resultant tarball contains the .git subdirectory. Could anybody point out how I could prevent it being included?

+1  A: 

This works:

<?xml version="1.0"?>
<project name="test" default="tar">
        <target name="tar">
            <tar
                destfile="sali-src-${version}.tgz"
                basedir="${basedir}"
                compression="gzip"
                excludes=".git/**, .gitignore/**, **/*.ipr, **/*.iws, **/*.iml">
            </tar>
        </target>
</project>

Your patterns were wrong, for more information about patterns read here: http://ant.apache.org/manual/dirtasks.html#patterns

DeletedAccount
+1  A: 

Ant has pre-configured default excludes that prevent directory-based tasks from processing control files for CVS, Subversion and VSS. Unfortunately, these defaults don't cover any other version control systems. However, you can modify the defaults using the <defaultexcludes> task:

<defaultexcludes add="**/.git/**,**/.gitignore"/>

This will exclude your Git files from any subsequent processing (so every subsequent use of <tar>, <javac>, <jar> or similar will ignore the control files).

Dan Dyer