Bolek Tekielski
Bolek Tekielski

Reputation: 1214

phing - delete directory contents without directory itself

I am trying to automate my PHP build, part of it is deleting selected content from a directory, as in below snippet

<delete verbose="${phing.verbose}">
    <fileset dir="${svn.exportDir}/includes" casesensitive="false">
        <exclude name="alerts.php"/>
        <exclude name="config.php"/>
        <exclude name="${client.name}_config.php"/>
        <exclude name="defaults.php"/>
        <exclude name="func.inc.php"/>
    </fileset>
</delete>

Now above code does remove includes folder as well, which is obviously undesirable. Phing does not understand

 dir="${svn.exportDir}/includes/**"

(directory includes/** not found), and adding

<exclude name="${svn.exportDir}/includes"/>

to delete task is kind of awkward, so I was wondering whether there is a better way to remove selected content from directory with phing?

Upvotes: 2

Views: 1632

Answers (2)

Marek Vantuch
Marek Vantuch

Reputation: 21

I have just tried it myself and the same code would not delete the include folder. Only way to make it do so was to set the includeemptydirs to true. Maybe it's a version problem, but still, I would try calling it like this:

<delete includeemptydirs="false">
    <fileset dir="folder" casesensitive="false">
        <exclude name="excluded.php"/>
    </fileset>
</delete>

Upvotes: 0

c33s
c33s

Reputation: 2642

it is a know bug, see http://www.phing.info/trac/ticket/796 should be working with versions 2.9+

for me it currently does not work on 2.9.1

Upvotes: 1

Related Questions