You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Steve Allan <st...@wrq.com> on 2002/04/26 21:02:50 UTC

Trying to delete files not under source control

Hi,

I'm trying to write an Ant target that will delete all files under a given
directory that are not under Perforce version control.  My plan was to use
'p4 have' to create an exclude list which I could then pass to the <delete>
task.  

On my win2k box, 'p4 have' will return output that looks like

  //project/version/foo.java#1 - d:\project\build\foo.java

which I can pipe through sed to get just

 d:\project\build\foo.java

So I tried this in my ant task:

 <exec executable = "p4" outputproperty = "shipFilesPerfoce">
    <arg line = "have ship\... | sed -e 's/.*\#.*- //' "/>
 </exec>

but exec is stripping the quotes from my sed command, at least that's how it
looks with ant -v, and I'm getting back the output of p4 have unfiltered.
And since <delete> doesn't support a <mapper> (I wonder why that is?), I
can't figure out how to filter the output from inside Ant.

Even if I could get the above to work, I'm not sure how I'd get the contents
of 'shipFilesPerforce' into a form that excludes will take.

As you can see, I'm quite lost. Can anyone suggest a sane way to approach
this problem?

Thanks.

-- Steve __

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Trying to delete files not under source control

Posted by Diane Holt <ho...@yahoo.com>.
Well, it ain't pretty (maybe my brain's just too rattled from the wildlife
nightmare I've been living with the past week to come up with anything
better)...

Actually, it wouldn't be all that bad except for two (I think evil) things
about a couple of tasks -- namely, <delete> and <filelist>. Firstly, for
some reason, <delete> has deprecated the 'excludes' attribute, so it's
going to wag a nasty DEPRECATED finger at you for using it. Secondly,
<filelist> insists you specify a 'dir' attribute -- which, frankly, makes
no sense to me at all (whywhywhy??).

Anyway, with that all said, and assuming you're in a position to use
Ant1.5 (soon to go beta ;), here 'tis:
  <target name="doit">
    <exec executable="p4" outputproperty="p4files" vmlauncher="no">
      <arg line='have | cut -d"-" -f2'/>
    </exec>
    <filelist id="p4files" dir="none" files="${p4files}"/>
    <pathconvert pathsep="," property="shipFilesPerforce" refid="p4files">
      <map
from="${basedir}${file.separator}none${file.separator}${basedir}${file.separator}"
to=""/>
    </pathconvert>
    <echo>shipFilesPerforce = ${shipFilesPerforce}</echo>
  </target>

Note that I didn't include the actual <delete> task (since I don't trust
myself to not do something incredibly stoopid today and end up deleting
all my files again!), but that part should be trivial, now that you have a
comma-separated list to specify to the (barking) 'excludes' attribute (but
I'd run it with just the <echo> first, if I was you :)

P.S. If you're not allowed to go with 1.5, let me know, and I'll whip up a
Javascript for you (beats doin the dishes :)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>