Bug 20687 - [PATCH] Enhance ExecOn with DirSets
Summary: [PATCH] Enhance ExecOn with DirSets
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: nightly
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 1.6
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-11 18:35 UTC by Gus Heck
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments
patch file adding support for dirsets to ExecOn.java (13.17 KB, patch)
2003-06-11 18:37 UTC, Gus Heck
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gus Heck 2003-06-11 18:35:24 UTC
As per my corespondance with Stefan on the dev list, 

http://marc.theaimsgroup.com/?l=ant-dev&m=105367047624558&w=2 

I have added dirset support to ExecOn.java (and thus to attrib, chmod, chgrp,
and chown). Making it work and not messing up the old type=file but not
requiring type=dir to use dirsets took a little thinking. I settled on an
implementation that esentially checks to see if it is handling a dirset and
gives the nested dirset priorety over the type="file". This seems to provide
full back compatability and the nice feature that you can still control the
behavior of filesets with type="file" and then slip in a few directories with a
dirset.

The cost of course is that reading type="file" in the top line of a long chmod,
nolonger guarantees that nothing below represents a directory, but only
specifies how filesets will be handled.

Not specifying type is the same as specifying type="file" so people who just
want to use a dirset can just use it.
Comment 1 Gus Heck 2003-06-11 18:37:01 UTC
Created attachment 6769 [details]
patch file adding support for dirsets to ExecOn.java
Comment 2 Stefan Bodewig 2003-06-24 09:18:54 UTC
I've modified the patch slightly (well, the docs more than slightly 8-).  Let me
know whether I've broken something.

<dirsets> will now also ignore type="both" as that seemed closer to the intent
to me.

Should appear in nightly build 2003-06-25.

There is a strange part in the ExecuteOn patch that adds a paragraph about order
to javdocs for setMaxparallel - I assumed it should have gone to addDirset and
moved it there.  There's been no patch to apply.html, so I made up my own.
Comment 3 Gus Heck 2003-06-24 17:03:18 UTC
hmm that strange part I think is an accidental paste. I think I might have
pasted in some code from elsewhere and then cut this out. 

Since clicking with the scroll wheel pastes for me, scrolling fast can drop
things in. This one got lucky enough to land in a comment and be a comment too,
and thus escaped notice (the usual result when this happens is just a compiler
error which is easily fixed).

A little grepping reveals that I pasted from subant... as an example of adding
dirsets I think. That fragment should simply be eliminated. I am reopening until
my doc error is fixed. Let me know if you want a patch for it.

As a further note, I will paste below my build file for checking this
functionality. Not a junit test case, but with java not understanding groups and
owners, this will have to do. 

<?xml version="1.0"?>

<project name="test" default="def" basedir=".">
  <target name="def">
    <delete>
      <fileset dir="." includes="test-*"/>
    </delete>
    <mkdir dir="test-fs"/>
    <mkdir dir="test-ds"/>
    <touch file="test-ffs"/>
    <touch file="test-fds"/>
    <apply type="both" executable="chmod">
      <arg value="444"/>
      <fileset dir="." includes="test-*"/>
    </apply>
    <chmod perm="777" type="file">
      <fileset dir="." includes="*fs"/>
      <dirset dir="." includes="*ds"/>
    </chmod> 
  </target>
</project>

This should result in something that looks like this when you do ls -l:

drwxrwxrwx    2 gus      gus          4096 Jun 24 12:15 test-ds
-r--r--r--    1 gus      gus             0 Jun 24 12:28 test-fds
-rwxrwxrwx    1 gus      gus             0 Jun 24 12:28 test-ffs
dr--r--r--    2 gus      gus          4096 Jun 24 12:15 test-fs


hmm perhaps something can be done with File.canWrite() now that I think of it...
 can't do it today though.
Comment 4 Stefan Bodewig 2003-06-25 12:16:30 UTC
[bodewig@bodewig tmp]$ ls -ld test-*
drwxrwxrwx    2 bodewig  bodewig      4096 Jun 25 14:11 test-ds
-r--r--r--    1 bodewig  bodewig         0 Jun 25 14:11 test-fds
-rwxrwxrwx    1 bodewig  bodewig         0 Jun 25 14:11 test-ffs
dr--r--r--    2 bodewig  bodewig      4096 Jun 25 14:11 test-fs

so it works on my machine.

I've removed the javadoc snippet (and never use the scroll wheel of my mouse ;-).