bodewig 2003/06/24 02:16:11
Modified: . WHATSNEW
docs/manual/CoreTasks apply.html chmod.html
docs/manual/OptionalTasks attrib.html chgrp.html chown.html
src/main/org/apache/tools/ant/taskdefs ExecuteOn.java
Log:
Add support for nested dirsets to <apply> and thus to a couple of
subclass-tasks as well.
PR: 20687
Submitted by: Gus Heck <gus dot heck at olin dot edu>
Revision Changes Path
1.443 +7 -7 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.442
retrieving revision 1.443
diff -u -r1.442 -r1.443
--- WHATSNEW 24 Jun 2003 08:44:02 -0000 1.442
+++ WHATSNEW 24 Jun 2003 09:16:10 -0000 1.443
@@ -335,13 +335,13 @@
* <mail> has a new attribute encoding. Bugzilla Report 15434.
* <mail> has new attributes user and password for SMTP auth.
-maillogger can also use this.
-The implementation only with JavaMail (encoding="MIME").
-Implementation with plain mail remains to do.
-Bugzilla Report 5969.
+ maillogger can also use this.
+ The implementation only works with JavaMail (encoding="MIME").
+ Implementation with plain mail remains to do.
+ Bugzilla Report 5969.
* <mail> and mailloger support SMTP over TLS/SSL
-Bugzilla Report 19180.
+ Bugzilla Report 19180.
* <zipfileset> can now be defined in the main body of a project
and referred to with refid="xyz". Bugzilla Report 17007.
@@ -404,8 +404,8 @@
* With the new addsourcefile attribute, you can make <apply> ommit the
source file names from the command line. Bugzilla Report 13654.
-* <apply> and <chmod> now support nested <filelist>s as well.
- Bugzilla Report 15929.
+* <apply> and <chmod> now support nested <filelist>s as well as <dirset>s.
+ Bugzilla Reports 15929 and 20687.
* <apply> and <chmod> will display a summary if you set the new
verbose attribute to true. Bugzilla Report 19883.
1.22 +13 -4 ant/docs/manual/CoreTasks/apply.html
Index: apply.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/CoreTasks/apply.html,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- apply.html 19 May 2003 12:18:08 -0000 1.21
+++ apply.html 24 Jun 2003 09:16:10 -0000 1.22
@@ -15,9 +15,10 @@
the command is only executed when Ant is run on one of the specified
operating
systems.</p>
<p>The files and/or directories of a number of <a
-href="../CoreTypes/fileset.html">FileSet</a>s or <a
-href="../CoreTypes/filelist.html">FileList</a>s are passed as arguments
-to the system command.</p>
+href="../CoreTypes/fileset.html">FileSet</a>s, <a
+href="../CoreTypes/dirset.html">DirSet</a>s (<em>since Ant 1.6</em>)
+or <a href="../CoreTypes/filelist.html">FileList</a>s (<em>since Ant
+1.6</em>) are passed as arguments to the system command.</p>
<p>If you specify a nested <a
href="../CoreTypes/mapper.html">mapper</a> and the <i>dest</i> attribute,
the timestamp of each source file is compared to the timestamp of a
@@ -137,7 +138,10 @@
<td valign="top">One of <i>file</i>, <i>dir</i> or
<i>both</i>. If set to <i>file</i>, only the names of plain
files will be sent to the command. If set to <i>dir</i>, only
- the names of directories are considered.</td>
+ the names of directories are considered.<br>
+ <strong>Note:</strong> The type attribute does not apply to
+ nested <i>dirset</i>s - <i>dirset</i>s always implicitly
+ assume type to be <i>dir</i>.</td>
<td align="center" valign="top">No, default is <i>file</i></td>
</tr>
<tr>
@@ -191,6 +195,11 @@
<p>You can use any number of nested <code><filelist></code>
elements to define the files for this task and refer to
<code><filelist></code>s defined elsewhere.</p>
+<h4>dirset</h4>
+<p><em>Since Ant 1.6</em></p>
+<p>You can use any number of nested <code><dirset></code>
+elements to define the directories for this task and refer to
+<code><dirset></code>s defined elsewhere.</p>
<h4>arg</h4>
<p>Command line arguments should be specified as nested
<code><arg></code> elements. See <a
1.14 +35 -8 ant/docs/manual/CoreTasks/chmod.html
Index: chmod.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/CoreTasks/chmod.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- chmod.html 23 May 2003 13:40:36 -0000 1.13
+++ chmod.html 24 Jun 2003 09:16:10 -0000 1.14
@@ -15,10 +15,12 @@
<p>See the section on <a
href="../dirtasks.html#directorybasedtasks">directory based
tasks</a>, on how the inclusion/exclusion of files works, and how to
write patterns.</p>
-<p>This task holds an implicit <a
href="../CoreTypes/fileset.html">FileSet</a> and
-supports all of FileSet's attributes and nested elements
-directly. More FileSets can be specified using nested
-<code><fileset></code> elements.</p>
+
+<p>This task holds an implicit <a
+href="../CoreTypes/fileset.html">FileSet</a> and supports all of
+FileSet's attributes and nested elements directly. More sets can be
+specified using nested <code><fileset></code> or
+<code><dirset></code> (<em>since Ant 1.6</em>) elements. </p>
<p>Starting with Ant 1.6, this task also supports nested <a
href="../CoreTypes/filelist.html">filelist</a>s.</p>
@@ -75,7 +77,10 @@
<td valign="top">One of <i>file</i>, <i>dir</i> or
<i>both</i>. If set to <i>file</i>, only the permissions of
plain files are going to be changed. If set to <i>dir</i>, only
- the directories are considered.</td>
+ the directories are considered.<br>
+ <strong>Note:</strong> The type attribute does not apply to
+ nested <i>dirset</i>s - <i>dirset</i>s always implicitly
+ assume type to be <i>dir</i>.</td>
<td align="center" valign="top">No, default is <i>file</i></td>
</tr>
<tr>
@@ -100,7 +105,8 @@
UNIX system.</p>
<blockquote>
<pre>
- <chmod dir="${dist}/bin" perm="ugo+rx"
includes="**/*.sh"/>
+<chmod dir="${dist}/bin" perm="ugo+rx"
+ includes="**/*.sh"/>
</pre>
</blockquote>
<p>makes all ".sh" files below <code>${dist}/bin</code>
@@ -120,8 +126,29 @@
group on a UNIX system. In addition all files belonging to a FileSet
with <code>id</code> <code>other.shared.sources</code> get the same
permissions.</p>
-<hr><p align="center">Copyright © 2000-2003 Apache Software Foundation.
All rights
-Reserved.</p>
+
+<blockquote>
+<pre>
+<chmod perm="go-rwx" type="file">
+ <fileset dir="/web">
+ <include name="**/*.cgi"/>
+ <include name="**/*.old"/>
+ </fileset>
+ <dirset dir="/web">
+ <include name="**/private_*"/>
+ </dirset>
+</chmod>
+</pre>
+</blockquote>
+
+<p>keeps non-owners from touching cgi scripts, files with a <code>.old</code>
+extension or directories begining with <code>private_</code>. A directory
+ending in <code>.old</code> or a file begining with private_ would remain
+unaffected.</p>
+
+<hr>
+<p align="center">Copyright © 2000-2003 Apache Software Foundation.
+All rights Reserved.</p>
</body>
</html>
1.5 +8 -4 ant/docs/manual/OptionalTasks/attrib.html
Index: attrib.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/OptionalTasks/attrib.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- attrib.html 23 May 2003 13:40:36 -0000 1.4
+++ attrib.html 24 Jun 2003 09:16:10 -0000 1.5
@@ -16,10 +16,11 @@
4 possible permissions has its own attribute, matching the arguments
for the attrib command.</p>
-<p><a href="../CoreTypes/fileset.html">FileSet</a>s or <a
+<p><a href="../CoreTypes/fileset.html">FileSet</a>s,
+<a href="../CoreTypes/dirset.html">DirSet</a>s or <a
href="../CoreTypes/filelist.html">FileList</a>s can be specified using
-nested <code><fileset></code> and <code><filelist></code>
-elements.</p>
+nested <code><fileset></code>, <code><dirset></code> and
+<code><filelist></code> elements.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -56,7 +57,10 @@
<td valign="top">type</td>
<td valign="top">One of <i>file</i>, <i>dir</i> or <i>both</i>. If set to
<i>file</i>, only the permissions of plain files are going to be
changed.
- If set to <i>dir</i>, only the directories are considered.</td>
+ If set to <i>dir</i>, only the directories are considered.<br>
+ <strong>Note:</strong> The type attribute does not apply to
+ nested <i>dirset</i>s - <i>dirset</i>s always implicitly
+ assume type to be <i>dir</i>.</td>
<td align="center" valign="top">No, default is <i>file</i></td>
</tr>
<tr>
1.4 +31 -7 ant/docs/manual/OptionalTasks/chgrp.html
Index: chgrp.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/OptionalTasks/chgrp.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- chgrp.html 21 May 2003 08:55:35 -0000 1.3
+++ chgrp.html 24 Jun 2003 09:16:10 -0000 1.4
@@ -16,10 +16,11 @@
atribute is equivalent to the coresponding argument for the chgrp
command.</p>
-<p><a href="../CoreTypes/fileset.html">FileSet</a>s or <a
+<p><a href="../CoreTypes/fileset.html">FileSet</a>s,
+<a href="../CoreTypes/dirset.html">DirSet</a>s or <a
href="../CoreTypes/filelist.html">FileList</a>s can be specified using
-nested <code><fileset></code> and <code><filelist></code>
-elements.</p>
+nested <code><fileset></code>, <code><dirset></code> and
+<code><filelist></code> elements.</p>
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -51,7 +52,10 @@
<td valign="top">One of <i>file</i>, <i>dir</i> or
<i>both</i>. If set to <i>file</i>, only the group of
plain files are going to be changed. If set to <i>dir</i>, only
- the directories are considered.</td>
+ the directories are considered.<br>
+ <strong>Note:</strong> The type attribute does not apply to
+ nested <i>dirset</i>s - <i>dirset</i>s always implicitly
+ assume type to be <i>dir</i>.</td>
<td align="center" valign="top">No, default is <i>file</i></td>
</tr>
<tr>
@@ -78,9 +82,9 @@
UNIX system.</p>
<blockquote>
<pre>
- <chgrp group="coders">
- <fileset dir="${dist}/bin"
includes="**/*.sh"/>
- </chgrp>
+<chgrp group="coders">
+ <fileset dir="${dist}/bin" includes="**/*.sh"/>
+</chgrp>
</pre>
</blockquote>
<p>makes all ".sh" files below <code>${dist}/bin</code>
@@ -100,6 +104,26 @@
system. In addition all files belonging to a FileSet
with <code>id</code> <code>other.shared.sources</code> get the same
group.</p>
+
+<blockquote>
+<pre>
+<chgrp group="webdev" type="file">
+ <fileset dir="/web">
+ <include name="**/*.test.jsp"/>
+ <include name="**/*.new"/>
+ </fileset>
+ <dirset dir="/web">
+ <include name="**/test_*"/>
+ </dirset>
+</chmod>
+</pre>
+</blockquote>
+
+<p>makes all <code>.test.jsp</code>, and <code>.new</code> files belong to
+group webdev. Directories begining with <code>test_</code> also will belong
+to webdev, but if there is a directory that ends in <code>.new</code> or a
file
+that begins with <code>test_</code> it will be unaffected.</p>
+
<hr>
<p align="center">Copyright © 2002-2003 Apache Software
1.4 +29 -4 ant/docs/manual/OptionalTasks/chown.html
Index: chown.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/OptionalTasks/chown.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- chown.html 21 May 2003 08:55:35 -0000 1.3
+++ chown.html 24 Jun 2003 09:16:10 -0000 1.4
@@ -16,10 +16,12 @@
atribute is equivalent to the coresponding argument for the chown
command.</p>
-<p><a href="../CoreTypes/fileset.html">FileSet</a>s or <a
+<p><a href="../CoreTypes/fileset.html">FileSet</a>s,
+<a href="../CoreTypes/dirset.html">DirSet</a>s or <a
href="../CoreTypes/filelist.html">FileList</a>s can be specified using
-nested <code><fileset></code> and <code><filelist></code>
-elements.</p>
+nested <code><fileset></code>, <code><dirset></code> and
+<code><filelist></code> elements.</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
@@ -51,7 +53,10 @@
<td valign="top">One of <i>file</i>, <i>dir</i> or
<i>both</i>. If set to <i>file</i>, only the owner of
plain files are going to be changed. If set to <i>dir</i>, only
- the directories are considered.</td>
+ the directories are considered.<br>
+ <strong>Note:</strong> The type attribute does not apply to
+ nested <i>dirset</i>s - <i>dirset</i>s always implicitly
+ assume type to be <i>dir</i>.</td>
<td align="center" valign="top">No, default is <i>file</i></td>
</tr>
<tr>
@@ -100,6 +105,26 @@
system. In addition all files belonging to a FileSet
with <code>id</code> <code>other.shared.sources</code> get the same
owner.</p>
+
+<blockquote>
+<pre>
+<chown owner="webadmin" type="file">
+ <fileset dir="/web">
+ <include name="**/*.cgi"/>
+ <include name="**/*.old"/>
+ </fileset>
+ <dirset dir="/web">
+ <include name="**/private_*"/>
+ </dirset>
+</chmod>
+</pre>
+</blockquote>
+
+<p>makes cgi scripts, files with a <code>.old</code> extension or
+directories begining with <code>private_</code> belong to the user named
+webadmin. A directory ending in <code>.old</code> or a file begining with
+<code>private_</code> would remain unaffected.</p>
+
<hr>
<p align="center">Copyright © 2002-2003 Apache Software
Foundation. All rights Reserved.</p>
1.40 +31 -4 ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
Index: ExecuteOn.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- ExecuteOn.java 19 May 2003 12:18:08 -0000 1.39
+++ ExecuteOn.java 24 Jun 2003 09:16:10 -0000 1.40
@@ -62,6 +62,8 @@
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.AbstractFileSet;
+import org.apache.tools.ant.types.DirSet;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileList;
import org.apache.tools.ant.types.FileSet;
@@ -81,7 +83,8 @@
*/
public class ExecuteOn extends ExecTask {
- protected Vector filesets = new Vector();
+ protected Vector filesets = new Vector(); // contains AbstractFileSet
+ // (both DirSet and FileSet)
private Vector filelists = new Vector();
private boolean relative = false;
private boolean parallel = false;
@@ -110,6 +113,20 @@
}
/**
+ * Adds directories to operate on.
+ *
+ * <p><em>Note that the directories will be added to the build
+ * path in no particular order, so if order is significant, one
+ * should use a file list instead!</em></p>
+ *
+ * @param set the DirSet to add.
+ *
+ * @since Ant 1.6
+ */
+ public void addDirset(DirSet set) {
+ filesets.addElement(set);
+ }
+ /**
* Source files to operate upon.
*/
public void addFilelist(FileList list) {
@@ -274,11 +291,21 @@
Vector fileNames = new Vector();
Vector baseDirs = new Vector();
for (int i = 0; i < filesets.size(); i++) {
- FileSet fs = (FileSet) filesets.elementAt(i);
+ String currentType = type;
+ AbstractFileSet fs = (AbstractFileSet) filesets.elementAt(i);
+ if (fs instanceof DirSet) {
+ if (!"dir".equals(type)) {
+ log("Found a nested dirset but type is " + type + ".
"
+ + "Temporarily switching to type=\"dir\" on the"
+
+ " assumption that you really did mean" +
+ " <dirset> not <fileset>.", Project.MSG_DEBUG);
+ currentType = "dir";
+ }
+ }
File base = fs.getDir(getProject());
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
- if (!"dir".equals(type)) {
+ if (!"dir".equals(currentType)) {
String[] s = getFiles(base, ds);
for (int j = 0; j < s.length; j++) {
totalFiles++;
@@ -287,7 +314,7 @@
}
}
- if (!"file".equals(type)) {
+ if (!"file".equals(currentType)) {
String[] s = getDirs(base, ds);;
for (int j = 0; j < s.length; j++) {
totalDirs++;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]