tags:

views:

85

answers:

1

When creating a zip from ant, how can I exclude all sub directories and files from a given directory?

I have tried the following but it doesn't seem to prevent them from being included in the zip

<target name="zip">
    <zip destfile="C:\Projects\example\builds\.zip"
            excludes="C:\Projects\example\logs\**\*.*">
    ...

    ...
    </zip>
</target>

From reading the documentation, and from reading the ant definitive guide I would assume that **\ should exclude any directory, and *.* would exclude any file of any extension

I want to include the logs directory, but nothing inside it

thanks

+1  A: 

I would recommend the following:

  1. Change the name of your destfile to "C:\Projects\example\builds\logs.zip"
  2. Set your basedir to "C:\Projects\example\"
  3. Change your excludes value to "C:\Projects\example\logs\**\*" (that means any file)

Another option might be to use the project-defined basedir, and change all your paths to relative UNIX-like values.

mlschechter