Yeah, I have a feeling you are running into some problem having to do with
non-empty subdirectories.  Usually some creative sorting, etc., can help.
 The delete task should know how to handle this with filesets; I believe
its page in the manual mentions this very problem. Therefore you might try
using the pathconvert task to create a list of includes for a fileset and
pass *that* to the delete task. Keep us updated on your progress.

Matt


On Tue, Feb 11, 2014 at 9:30 AM, Kimpton, C (Chris) <
chris.kimp...@rabobank.com> wrote:

> Good idea.
>
> It initially worked ok, when the directories were empty, but when I added
> files to each (touch steps below), that caused the script to not delete any
> files.
>
> And now I see that it does not work on Windows either ...  my tests used
> empty directories.
>
> Does this sound like a bug or am I missing some subtlety around resource
> collections/dirset and non-empty subdirectories...
>
> Thanks in advance.
>
> Here is my test file:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="resource-collection-delete-sample" default="tryit">
>
>     <property name="test-dir" value="${basedir}/testdata"/>
>
>     <target name="setup-files">
>         <delete dir="${test-dir}"/>
>         <mkdir dir="${test-dir}"/>
>         <mkdir dir="${test-dir}/xxfile1"/>
>         <mkdir dir="${test-dir}/1"/>
>         <touch file="${test-dir}/1/test"/>
>         <sleep milliseconds="100" />
>         <mkdir dir="${test-dir}/2"/>
>         <touch file="${test-dir}/2/test"/>
>         <sleep milliseconds="100" />
>         <mkdir dir="${test-dir}/3"/>
>         <touch file="${test-dir}/3/test"/>
>         <sleep milliseconds="100" />
>         <mkdir dir="${test-dir}/4"/>
>         <touch file="${test-dir}/4/test"/>
>         <sleep milliseconds="100" />
>         <mkdir dir="${test-dir}/5"/>
>         <touch file="${test-dir}/5/test"/>
>         <sleep milliseconds="100" />
>         <mkdir dir="${test-dir}/6"/>
>         <touch file="${test-dir}/6/test"/>
>         <sleep milliseconds="100" />
>         <touch file="${test-dir}/44" />
>         <sleep milliseconds="100" />
>         <!-- create some files -->
>     </target>
>
>     <target name="delete-files">
>         <!-- delete all but last few old release directories -->
>         <resources id="resource-all-dirs">
>             <dirset dir="${test-dir}" >
>                 <filename regex="^\d+$" />
>             </dirset>
>         </resources>
>         <resources id="resource-last-3-dirs">
>             <last count="3">
>                 <sort>
>                     <dirset dir="${test-dir}" >
>                         <filename regex="^\d+$" />
>                     </dirset>
>                     <date />
>                 </sort>
>             </last>
>         </resources>
>         <delete verbose="true">
>             <difference>
>                 <resources refid="resource-all-dirs"/>
>                 <resources refid="resource-last-3-dirs" />
>             </difference>
>         </delete>
>     </target>
>
>     <target name="tryit" depends="setup-files, delete-files">
>     </target>
>
> </project>
>
>
>
>
> -----Original Message-----
> From: Matt Benson [mailto:gudnabr...@gmail.com]
> Sent: 11 February 2014 14:15
> To: Ant Users List
> Subject: Re: Resource collections - Linux vs. windows
>
> Can you expand your example into a self-contained example that builds up
> an appropriate structure first, then still fails on Linux?
>
> Matt
>
>
> On Tue, Feb 11, 2014 at 2:21 AM, Kimpton, C (Chris) <
> chris.kimp...@rabobank.com> wrote:
>
> > Hi,
> >
> > I have a target that is trying to delete some directories, all but the
> > last few.  It works as expected (I believe - it deletes files when
> > expected) on my dev box (windows), but is not deleting anything on the
> > build server (Linux):
> >
> > It builds up 2 resource collections - one for all directories and one
> > for the last few and then does a delete based on the difference.
> >
> >         <resources id="resource-all-dirs">
> >             <dirset dir="${release-base-dir}" >
> >                 <filename regex="^\d+$" />
> >             </dirset>
> >         </resources>
> >
> >         <resources id="resource-last-3-dirs">
> >             <last count="4">
> >                 <sort>
> >                     <dirset dir="${release-base-dir}" >
> >                         <filename regex="^\d+$" />
> >                     </dirset>
> >                     <date />
> >                 </sort>
> >             </last>
> >         </resources>
> >
> >         <delete verbose="true">
> >             <difference>
> >                 <resources refid="resource-all-dirs"/>
> >                 <resources refid="resource-last-3-dirs" />
> >             </difference>
> >         </delete>
> >
> > I have tried running with debug and/or verbose but that does not seem
> > to add anything.  Using version 1.9.3.
> >
> > Any tips on how to track down the issue?
> >
> > Cheers,
> > Chris
> >
> > _____________________________________________________________
> >
> > This email (including any attachments to it) is confidential, legally
> > privileged, subject to copyright and is sent for the personal
> > attention of the intended recipient only. If you have received this
> > email in error, please advise us immediately and delete it. You are
> > notified that disclosing, copying, distributing or taking any action
> > in reliance on the contents of this information is strictly
> > prohibited. Although we have taken reasonable precautions to ensure no
> > viruses are present in this email, we cannot accept responsibility for
> > any loss or damage arising from the viruses in this email or
> > attachments. We exclude any liability for the content of this email,
> > or for the consequences of any actions taken on the basis of the
> > information provided in this email or its attachments, unless that
> information is subsequently confirmed in writing.
> > _____________________________________________________________
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
> For additional commands, e-mail: user-h...@ant.apache.org
>
>

Reply via email to