2
votes

I'm working on an Ant script to help with a Wordpress deployment (I know...). The idea here is to:

  • delete the entire vendor directory.
  • delete the entire public_html/wp directory.
  • delete everything from public_html/content/plugins except for the one PHP file: public_html/content/plugins/w3tc-wp-loader.php.

This is what I've tried (along many variations):

<delete failonerror="false" quiet="false" includeEmptyDirs="true">
    <fileset dir="vendor" />
    <fileset dir="public_html/wp" />
    <fileset dir="public_html/content/plugins">
        <exclude name="w3tc-wp-loader.php" />
    </fileset>
</delete>

This kinda works:

  • it deletes the contents of the vendor directory except for a few .gitignore files that exist in subdirs, so those files and their parent dirs still exist (i.e. vendor/composer/installers/.gitignore).
  • public_html/wp is deleted, as expected.
  • public_html/content/plugins is left containing a bunch of subdirectories, each of which is empty (except one has a .gitignore file). The excluded file noted in the Ant script is left, as expected.

Any idea why a) the empty dirs aren't removed and b) .gitignore files seem to stay as well (as well as their parent dirs)? What am I doing wrong?

2

2 Answers

4
votes

What about this way:

<delete failonerror="false" quiet="false" includeemptydirs="true">
    <fileset dir="${root}" defaultexcludes="false">
       <include name="vendor/**" />
       <include name="public_html/wp/**" />
       <include name="public_html/content/plugins/**" />
       <exclude name="public_html/content/plugins/w3tc-wp-loader.php" />
    </fileset>
</delete>

where ${root} is the parent directory for vendor and public_html.

defaultexcludes="false" will make sure your .gitignores will be deleted as well.

3
votes

Your .gitignore files are excluded by default http://ant.apache.org/manual/dirtasks.html#defaultexcludes. To delete them add defaultexcludes="false" to fileset