Browse Source

allow chmod, chgrp, chown and attribute to be used outside of their native environment. PR 7624

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@714025 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
bee14ad0d4
10 changed files with 105 additions and 6 deletions
  1. +6
    -0
      WHATSNEW
  2. +18
    -0
      docs/manual/CoreTasks/chmod.html
  3. +1
    -1
      docs/manual/CoreTasks/conditions.html
  4. +19
    -0
      docs/manual/OptionalTasks/attrib.html
  5. +19
    -0
      docs/manual/OptionalTasks/chgrp.html
  6. +19
    -0
      docs/manual/OptionalTasks/chown.html
  7. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/Chmod.java
  8. +16
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  9. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
  10. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java

+ 6
- 0
WHATSNEW View File

@@ -528,6 +528,12 @@ Other changes:
or the number of symlinks was too big) will be removed. or the number of symlinks was too big) will be removed.
Bugzilla Report 36658. Bugzilla Report 36658.


* the os and osfamily attributes of <chown>, <chgrp>, <chmod> and
<attrib> can now be used to run the commands on operating systems
other than their "native" environment, i.e. non-Unix or non-Windows
operating systems repsectively.
Bugzilla Report 7624.

Changes from Ant 1.7.0 TO Ant 1.7.1 Changes from Ant 1.7.0 TO Ant 1.7.1
============================================= =============================================




+ 18
- 0
docs/manual/CoreTasks/chmod.html View File

@@ -57,6 +57,12 @@ little. POSIX recommends command line length limits of at least 4096
characters, this may give you an approximation for the number you characters, this may give you an approximation for the number you
could use as initial value for these experiments.</p> could use as initial value for these experiments.</p>


<p>By default this task won't do anything unless it detects it is
running on a Unix system. If you know for sure that you have a
"chmod" executable on your PATH that is command line compatible with
the Unix command, you can use the task's os attribute and set its
value to your current os.</p>

<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -132,6 +138,18 @@ could use as initial value for these experiments.</p>
Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td> Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">os</td>
<td valign="top">list of Operating Systems on which the command may be
executed.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">osfamily</td>
<td valign="top">OS family as used in
the <a href="conditions.html#os">&lt;os&gt;</a> condition.</td>
<td align="center" valign="top">No - defaults to "unix"</td>
</tr>
</table> </table>
<h3>Examples</h3> <h3>Examples</h3>
<blockquote><pre> <blockquote><pre>


+ 1
- 1
docs/manual/CoreTasks/conditions.html View File

@@ -87,7 +87,7 @@ href="uptodate.html">Uptodate</a> task, all attributes and nested
elements of that task are supported, the property and value attributes elements of that task are supported, the property and value attributes
are redundant and will be ignored.</p> are redundant and will be ignored.</p>


<h4>os</h4>
<a name="os"><h4>os</h4></a>
<p>Test whether the current operating system is of a given type. Each <p>Test whether the current operating system is of a given type. Each
defined attribute is tested and the result is true only if <i>all</i> defined attribute is tested and the result is true only if <i>all</i>
the tests succeed. the tests succeed.


+ 19
- 0
docs/manual/OptionalTasks/attrib.html View File

@@ -51,6 +51,12 @@ maxparallel attribute of this task to a non-zero value. The number to
use highly depends on the length of your file names (the depth of your use highly depends on the length of your file names (the depth of your
directory tree), so you'll have to experiment a little.</p> directory tree), so you'll have to experiment a little.</p>


<p>By default this task won't do anything unless it detects it is
running on a Windows system. If you know for sure that you have a
"attrib" executable on your PATH that is command line compatible with
the Windows command, you can use the task's os attribute and set its
value to your current os.</p>

<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -111,6 +117,19 @@ directory tree), so you'll have to experiment a little.</p>
unlimited. Defaults to unlimited. <em>Since Ant 1.6.</em></td> unlimited. Defaults to unlimited. <em>Since Ant 1.6.</em></td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">os</td>
<td valign="top">list of Operating Systems on which the command may be
executed.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">osfamily</td>
<td valign="top">OS family as used in
the <a href="../CoreTasks/conditions.html#os">&lt;os&gt;</a>
condition.</td>
<td align="center" valign="top">No - defaults to "windows"</td>
</tr>
</table> </table>


<h3>Examples</h3> <h3>Examples</h3>


+ 19
- 0
docs/manual/OptionalTasks/chgrp.html View File

@@ -54,6 +54,12 @@ little. POSIX recommends command line length limits of at least 4096
characters, this may give you an approximation for the number you characters, this may give you an approximation for the number you
could use as initial value for these experiments.</p> could use as initial value for these experiments.</p>


<p>By default this task won't do anything unless it detects it is
running on a Unix system. If you know for sure that you have a
"chgrp" executable on your PATH that is command line compatible with
the Unix command, you can use the task's os attribute and set its
value to your current os.</p>

<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -105,6 +111,19 @@ could use as initial value for these experiments.</p>
Defaults to <code>false</code>.</td> Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">os</td>
<td valign="top">list of Operating Systems on which the command may be
executed.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">osfamily</td>
<td valign="top">OS family as used in
the <a href="../CoreTasks/conditions.html#os">&lt;os&gt;</a>
condition.</td>
<td align="center" valign="top">No - defaults to "unix"</td>
</tr>


</table> </table>
<h3>Examples</h3> <h3>Examples</h3>


+ 19
- 0
docs/manual/OptionalTasks/chown.html View File

@@ -54,6 +54,12 @@ little. POSIX recommends command line length limits of at least 4096
characters, this may give you an approximation for the number you characters, this may give you an approximation for the number you
could use as initial value for these experiments.</p> could use as initial value for these experiments.</p>


<p>By default this task won't do anything unless it detects it is
running on a Unix system. If you know for sure that you have a
"chown" executable on your PATH that is command line compatible with
the Unix command, you can use the task's os attribute and set its
value to your current os.</p>

<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
@@ -104,6 +110,19 @@ could use as initial value for these experiments.</p>
Defaults to <code>false</code>.</td> Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
<tr>
<td valign="top">os</td>
<td valign="top">list of Operating Systems on which the command may be
executed.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">osfamily</td>
<td valign="top">OS family as used in
the <a href="../CoreTasks/conditions.html#os">&lt;os&gt;</a>
condition.</td>
<td align="center" valign="top">No - defaults to "unix"</td>
</tr>


</table> </table>
<h3>Examples</h3> <h3>Examples</h3>


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/Chmod.java View File

@@ -254,6 +254,7 @@ public class Chmod extends ExecuteOn {
* @return true if the os is valid. * @return true if the os is valid.
*/ */
protected boolean isValidOs() { protected boolean isValidOs() {
return Os.isFamily(Os.FAMILY_UNIX) && super.isValidOs();
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
} }
} }

+ 16
- 1
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -154,6 +154,14 @@ public class ExecTask extends Task {
this.os = os; this.os = os;
} }


/**
* List of operating systems on which the command may be executed.
* @since Ant 1.8.0
*/
public final String getOs() {
return os;
}

/** /**
* Sets a command line. * Sets a command line.
* @param cmdl command line. * @param cmdl command line.
@@ -396,6 +404,13 @@ public class ExecTask extends Task {
this.osFamily = osFamily.toLowerCase(Locale.US); this.osFamily = osFamily.toLowerCase(Locale.US);
} }


/**
* Restrict this execution to a single OS Family
* @since Ant 1.8.0
*/
public final String getOsFamily() {
return osFamily;
}


/** /**
* The method attempts to figure out where the executable is so that we can feed * The method attempts to figure out where the executable is so that we can feed
@@ -545,7 +560,7 @@ public class ExecTask extends Task {
*/ */
protected boolean isValidOs() { protected boolean isValidOs() {
//hand osfamily off to Os class, if set //hand osfamily off to Os class, if set
if (osFamily != null && !Os.isOs(osFamily, null, null, null)) {
if (osFamily != null && !Os.isFamily(osFamily)) {
return false; return false;
} }
//the Exec OS check is different from Os.isOs(), which //the Exec OS check is different from Os.isOs(), which


+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java View File

@@ -104,6 +104,7 @@ public abstract class AbstractAccessTask
* use the superclasses' test (user set). * use the superclasses' test (user set).
*/ */
protected boolean isValidOs() { protected boolean isValidOs() {
return Os.isFamily("unix") && super.isValidOs();
return getOs() == null && getOsFamily() == null
? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
} }
} }

+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java View File

@@ -172,11 +172,12 @@ public class Attrib extends ExecuteOn {


/** /**
* Check if the os is valid. * Check if the os is valid.
* Always include windows
* Defauls is to allow windows
* @return true if the os is valid. * @return true if the os is valid.
*/ */
protected boolean isValidOs() { protected boolean isValidOs() {
return Os.isFamily("windows") && super.isValidOs();
return getOs() == null && getOsFamily() == null ?
Os.isFamily(Os.WINDOWS) : super.isValidOs();
} }


private static String getSignString(boolean attr) { private static String getSignString(boolean attr) {


Loading…
Cancel
Save