[14627] | 1 | <html>
|
---|
| 2 |
|
---|
| 3 | <head>
|
---|
| 4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
| 5 | <title>Basename Task</title>
|
---|
| 6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
| 7 | </head>
|
---|
| 8 |
|
---|
| 9 | <body>
|
---|
| 10 |
|
---|
| 11 | <h2><a name="echo">Basename</a></h2>
|
---|
| 12 | <h3>Description</h3>
|
---|
| 13 | <p>
|
---|
| 14 | Task to determine the basename of a specified file, optionally minus a
|
---|
| 15 | specified suffix.
|
---|
| 16 | </p>
|
---|
| 17 | <p>
|
---|
| 18 | When this task executes, it will set the specified property to the
|
---|
| 19 | value of the last path element of the specified file. If <code>file</code> is a
|
---|
| 20 | directory, the basename will be the last directory element. If
|
---|
| 21 | <code>file</code> is a full-path, relative-path, or simple filename,
|
---|
| 22 | the basename will be the simple file name, without any directory elements.
|
---|
| 23 | </p>
|
---|
| 24 | <p>
|
---|
| 25 | <h3>Parameters</h3>
|
---|
| 26 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
| 27 | <tr>
|
---|
| 28 | <td valign="top"><b>Attribute</b></td>
|
---|
| 29 | <td valign="top"><b>Description</b></td>
|
---|
| 30 | <td align="center" valign="top"><b>Required</b></td>
|
---|
| 31 | </tr>
|
---|
| 32 | <tr>
|
---|
| 33 | <td valign="top">file</td>
|
---|
| 34 | <td valign="top">The path to take the basename of.</td>
|
---|
| 35 | <td valign="top" align="center">Yes</td>
|
---|
| 36 | </tr>
|
---|
| 37 | <tr>
|
---|
| 38 | <td valign="top">property</td>
|
---|
| 39 | <td valign="top">The name of the property to set.</td>
|
---|
| 40 | <td valign="top" align="center">Yes</td>
|
---|
| 41 | </tr>
|
---|
| 42 | <tr>
|
---|
| 43 | <td valign="top">suffix</td>
|
---|
| 44 | <td valign="top">The suffix to remove from the resulting basename
|
---|
| 45 | (specified either with or without the "<code>.</code>").</td>
|
---|
| 46 | <td valign="top" align="center">No</td>
|
---|
| 47 | </tr>
|
---|
| 48 | </table>
|
---|
| 49 |
|
---|
| 50 | <h3>Examples</h3>
|
---|
| 51 | <blockquote><pre>
|
---|
| 52 | <basename property="jar.filename" file="${lib.jarfile}"/>
|
---|
| 53 | </pre></blockquote>
|
---|
| 54 | will set <code>jar.filename</code> to
|
---|
| 55 | <code>myjar.jar</code>, if <code>lib.jarfile</code> is defined as either a
|
---|
| 56 | full-path filename (eg., <code>/usr/local/lib/myjar.jar</code>),
|
---|
| 57 | a relative-path filename (eg., <code>lib/myjar.jar</code>),
|
---|
| 58 | or a simple filename (eg., <code>myjar.jar</code>).
|
---|
| 59 | <blockquote><pre>
|
---|
| 60 | <basename property="cmdname" file="D:/usr/local/foo.exe"
|
---|
| 61 | suffix=".exe"/>
|
---|
| 62 | </pre></blockquote>
|
---|
| 63 | will set <code>cmdname</code> to <code>foo</code>.
|
---|
| 64 | <blockquote><pre>
|
---|
| 65 | <property environment="env"/>
|
---|
| 66 | <basename property="temp.dirname" file="${env.TEMP}"/>
|
---|
| 67 | </pre></blockquote>
|
---|
| 68 |
|
---|
| 69 | will set <code>temp.dirname</code> to the last directory element of
|
---|
| 70 | the path defined for the <code>TEMP</code> environment variable.</p>
|
---|
| 71 |
|
---|
| 72 | <hr>
|
---|
| 73 | <p align="center">Copyright © 2002,2004-2005 The Apache Software Foundation.
|
---|
| 74 | All rights Reserved.</p>
|
---|
| 75 |
|
---|
| 76 | </body>
|
---|
| 77 | </html>
|
---|
| 78 |
|
---|