You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/14 16:12:27 UTC
svn commit: r714025 - in /ant/core/trunk: ./ docs/manual/CoreTasks/
docs/manual/OptionalTasks/ src/main/org/apache/tools/ant/taskdefs/
src/main/org/apache/tools/ant/taskdefs/optional/unix/
src/main/org/apache/tools/ant/taskdefs/optional/windows/
Author: bodewig
Date: Fri Nov 14 07:12:26 2008
New Revision: 714025
URL: http://svn.apache.org/viewvc?rev=714025&view=rev
Log:
allow chmod, chgrp, chown and attribute to be used outside of their native environment. PR 7624
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/chmod.html
ant/core/trunk/docs/manual/CoreTasks/conditions.html
ant/core/trunk/docs/manual/OptionalTasks/attrib.html
ant/core/trunk/docs/manual/OptionalTasks/chgrp.html
ant/core/trunk/docs/manual/OptionalTasks/chown.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Chmod.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Nov 14 07:12:26 2008
@@ -528,6 +528,12 @@
or the number of symlinks was too big) will be removed.
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
=============================================
Modified: ant/core/trunk/docs/manual/CoreTasks/chmod.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/chmod.html?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/chmod.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/chmod.html Fri Nov 14 07:12:26 2008
@@ -57,6 +57,12 @@
characters, this may give you an approximation for the number you
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>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -132,6 +138,18 @@
Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td>
<td align="center" valign="top">No</td>
</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"><os></a> condition.</td>
+ <td align="center" valign="top">No - defaults to "unix"</td>
+ </tr>
</table>
<h3>Examples</h3>
<blockquote><pre>
Modified: ant/core/trunk/docs/manual/CoreTasks/conditions.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/conditions.html?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/conditions.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/conditions.html Fri Nov 14 07:12:26 2008
@@ -87,7 +87,7 @@
elements of that task are supported, the property and value attributes
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
defined attribute is tested and the result is true only if <i>all</i>
the tests succeed.
Modified: ant/core/trunk/docs/manual/OptionalTasks/attrib.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/attrib.html?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/attrib.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/attrib.html Fri Nov 14 07:12:26 2008
@@ -51,6 +51,12 @@
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>
+<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>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -111,6 +117,19 @@
unlimited. Defaults to unlimited. <em>Since Ant 1.6.</em></td>
<td align="center" valign="top">No</td>
</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"><os></a>
+ condition.</td>
+ <td align="center" valign="top">No - defaults to "windows"</td>
+ </tr>
</table>
<h3>Examples</h3>
Modified: ant/core/trunk/docs/manual/OptionalTasks/chgrp.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/chgrp.html?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/chgrp.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/chgrp.html Fri Nov 14 07:12:26 2008
@@ -54,6 +54,12 @@
characters, this may give you an approximation for the number you
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>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -105,6 +111,19 @@
Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td>
</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"><os></a>
+ condition.</td>
+ <td align="center" valign="top">No - defaults to "unix"</td>
+ </tr>
</table>
<h3>Examples</h3>
Modified: ant/core/trunk/docs/manual/OptionalTasks/chown.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/chown.html?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/chown.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/chown.html Fri Nov 14 07:12:26 2008
@@ -54,6 +54,12 @@
characters, this may give you an approximation for the number you
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>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -104,6 +110,19 @@
Defaults to <code>false</code>.</td>
<td align="center" valign="top">No</td>
</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"><os></a>
+ condition.</td>
+ <td align="center" valign="top">No - defaults to "unix"</td>
+ </tr>
</table>
<h3>Examples</h3>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Chmod.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Chmod.java?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Chmod.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Chmod.java Fri Nov 14 07:12:26 2008
@@ -254,6 +254,7 @@
* @return true if the os is valid.
*/
protected boolean isValidOs() {
- return Os.isFamily(Os.FAMILY_UNIX) && super.isValidOs();
+ return getOs() == null && getOsFamily() == null
+ ? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecTask.java Fri Nov 14 07:12:26 2008
@@ -155,6 +155,14 @@
}
/**
+ * 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.
* @param cmdl command line.
* @ant.attribute ignore="true"
@@ -396,6 +404,13 @@
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
@@ -545,7 +560,7 @@
*/
protected boolean isValidOs() {
//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;
}
//the Exec OS check is different from Os.isOs(), which
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/AbstractAccessTask.java Fri Nov 14 07:12:26 2008
@@ -104,6 +104,7 @@
* use the superclasses' test (user set).
*/
protected boolean isValidOs() {
- return Os.isFamily("unix") && super.isValidOs();
+ return getOs() == null && getOsFamily() == null
+ ? Os.isFamily(Os.FAMILY_UNIX) : super.isValidOs();
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java?rev=714025&r1=714024&r2=714025&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java Fri Nov 14 07:12:26 2008
@@ -172,11 +172,12 @@
/**
* Check if the os is valid.
- * Always include windows
+ * Defauls is to allow windows
* @return true if the os is valid.
*/
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) {