Browse Source

Added value attribute to <available>.

Submitted by:	Glenn McAllister <glennm@ca.ibm.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267991 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
b42831ce4b
3 changed files with 15 additions and 9 deletions
  1. +8
    -2
      docs/index.html
  2. +4
    -6
      src/main/org/apache/tools/ant/taskdefs/Available.java
  3. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/KeySubst.java

+ 8
- 2
docs/index.html View File

@@ -961,8 +961,9 @@ listed as <code>#IMPLIED</code>.</p>
<h3>Description</h3>
<p>Sets a property if a resource is available at runtime. This resource can be a
file resource, a class in classpath or a JVM system resource.</p>
<p>The value part of the properties being set is <i>true</i> if the resource is
present, otherwise, the property is not set.</p>
<p>If the resource is present, the property value is set to true by
default, otherwise the property is not set.  You can set the value to
something specific by using the value attribute.</p>
<p>Normally, this task is used to set properties that are useful to avoid target
execution depending on system parameters.</p>
<h3>Parameters</h3>
@@ -977,6 +978,11 @@ execution depending on system parameters.</p>
<td valign="top">the name of the property to set.</td>
<td valign="top" align="center">Yes</td>
</tr>
 <tr>
   <td valign="top">value</td>
   <td valign="top">the value to set the property to. Defaults to "true".</td>
   <td valign="top" align="center">No</td>
 </tr>
<tr>
<td valign="top">classname</td>
<td valign="top">the class to look for in classpath.</td>


+ 4
- 6
src/main/org/apache/tools/ant/taskdefs/Available.java View File

@@ -70,16 +70,14 @@ public class Available extends Task {
private String classname;
private File file;
private String resource;
private String value = "true";

public void setProperty(String property) {
this.property = property;
}

public void XsetClass(String classname) {
log("The class attribute is deprecated. " +
"Please use the classname attribute.",
Project.MSG_WARN);
this.classname = classname;
public void setValue(String value) {
this.value = value;
}

public void setClassname(String classname) {
@@ -99,7 +97,7 @@ public class Available extends Task {
if ((file != null) && !checkFile(file)) return;
if ((resource != null) && !checkResource(resource)) return;

this.project.setProperty(property, "true");
this.project.setProperty(property, value);
}

private boolean checkFile(File file) {


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/KeySubst.java View File

@@ -65,6 +65,8 @@ import java.util.*;
* setKeys method to understand how to do the substitutions.
*
* @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
*
* @deprecated KeySubst is deprecated. Use Filter + CopyDir instead.
*/
public class KeySubst extends Task {
private File source = null;
@@ -200,4 +202,4 @@ public class KeySubst extends Task {
finalString.append (origString.substring(i));
return finalString.toString();
}
}
}

Loading…
Cancel
Save