Browse Source

Make sure <basename> and <dirname> don't break property immutability

rules.

Minor corrections to their documentation.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272341 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
895ef094bb
4 changed files with 9 additions and 4 deletions
  1. +2
    -1
      docs/manual/CoreTasks/basename.html
  2. +1
    -1
      docs/manual/CoreTasks/dirname.html
  3. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/Basename.java
  4. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/Dirname.java

+ 2
- 1
docs/manual/CoreTasks/basename.html View File

@@ -55,7 +55,8 @@ a relative-path filename (eg., <code>lib/myjar.jar</code>),
or a simple filename (eg., <code>myjar.jar</code>).
<pre> &lt;basename property=&quot;cmdname&quot; file=&quot;D:/usr/local/foo.exe&quot; suffix=&quot;.exe&quot;/&gt;</pre>
will set <code>cmdname</code> to <code>foo</code>.
<pre> &lt;basename property=&quot;temp.dirname&quot; file=&quot;${env.TEMP}&quot;/&gt;</pre>
<pre> &lt;property environment=&quot;env&quot;/&gt;
&lt;basename property=&quot;temp.dirname&quot; file=&quot;${env.TEMP}&quot;/&gt;</pre>

will set <code>temp.dirname</code> to the last directory element of
the path defined for the <code>TEMP</code> environment variable.</p>


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

@@ -43,7 +43,7 @@ the directory will be the current directory.
will set <code>antfile.dir</code> to the directory path for
<code>${ant.file}</code>.
<pre> &lt;dirname property=&quot;foo.dirname&quot; file=&quot;foo.txt&quot;/&gt;</pre>
will set <code>foo.dirname</code> to the current directory.</p>
will set <code>foo.dirname</code> to the project's basedir.</p>

<hr>
<p align="center">Copyright &copy; 2002 Apache Software Foundation.


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

@@ -84,6 +84,8 @@ import org.apache.tools.ant.Task;
*
* @version $Revision$
*
* @since Ant 1.5
*
* @ant.task category="property"
*/

@@ -122,7 +124,7 @@ public class Basename extends Task {
int pos = value.indexOf('.');
value = value.substring(0, pos);
}
this.project.setProperty(property, value);
getProject().setNewProperty(property, value);
}
}
}


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

@@ -77,6 +77,8 @@ import org.apache.tools.ant.Task;
*
* @version $Revision$
*
* @since Ant 1.5
*
* @ant.task category="property"
*/

@@ -104,7 +106,7 @@ public class Dirname extends Task {
throw new BuildException("file attribute required", location);
} else {
String value = file.getParent();
this.project.setProperty(property, value);
getProject().setNewProperty(property, value);
}
}
}


Loading…
Cancel
Save