source: release-kits/lirk3/resources/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTasks/pathconvert.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 7.0 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>PathConvert Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="pathconvert">Pathconvert</a></h2>
12<h3>Description</h3>
13<p>Converts a nested <code>&lt;path&gt;</code> or reference to a Path,
14FileSet, DirSet, or FileList into a path
15form for a particular platform, and stores the result in a given property.
16It can also be used when you need
17to convert a Path, FileSet, or DirSet into a list, separated by a given
18character, such as a comma or space, or, conversely, to convert a list
19of files in a FileList into a path.
20</p>
21<p>Nested <code>&lt;map&gt;</code> elements can be specified to map Windows
22drive letters to Unix paths, and vice-versa.</p>
23<p>More complex transformations can be achieved using a nested
24<a href="../CoreTypes/mapper.html"><code>&lt;mapper&gt;</code></a>
25(since Ant 1.6.2).
26</p>
27
28<h3>Parameters</h3>
29<table border="1" cellpadding="2" cellspacing="0">
30 <tr>
31 <td valign="top"><b>Attribute</b></td>
32 <td valign="top"><b>Description</b></td>
33 <td align="center" valign="top"><b>Required</b></td>
34 </tr>
35 <tr>
36 <td valign="top">targetos</td>
37 <td valign="top">
38 The target architecture. Must be one of 'unix', 'windows',
39 'netware', 'tandem' or 'os/2'.
40 This is a shorthand mechanism for specifying both
41 <code>pathsep</code> and <code>dirsep</code>
42 according to the specified target architecture.
43 </td>
44 <td valign="top" align="center">No</td>
45 </tr>
46 <tr>
47 <td valign="top">dirsep</td>
48 <td valign="top">
49 The character(s) to use as the directory separator in the
50 generated paths.
51 </td>
52 <td valign="top" align="center">No, defaults to current JVM <tt>File.separator</tt></td>
53 </tr>
54 <tr>
55 <td valign="top">pathsep</td>
56 <td valign="top">
57 The character(s) to use as the path-element separator in the
58 generated paths.
59 </td>
60 <td valign="top" align="center">No, defaults to current JVM <tt>File.pathSeparator</tt></td>
61 </tr>
62 <tr>
63 <td valign="top">property</td>
64 <td valign="top">The name of the property in which to place the converted path.</td>
65 <td valign="top" align="center">Yes</td>
66 </tr>
67 <tr>
68 <td valign="top">refid</td>
69 <td valign="top">What to convert, given as a
70 <a href="../using.html#references">reference</a> to a
71 <code>&lt;path&gt;</code>, <code>&lt;fileset&gt;</code>,
72 <code>&lt;dirset&gt;</code>, or <code>&lt;filelist&gt;</code>
73 defined elsewhere</td>
74 <td valign="top" align="center">No; if omitted, a nested
75 <code>&lt;path&gt;</code> element must be supplied.</td>
76 </tr>
77 <td valign="top">setonempty</td>
78 <td valign="top">Should the property be set, even if the result
79 is the empty string?
80 <td valign="top" align="center">No; default is &quot;true&quot;.
81 </tr>
82</table>
83<h3>Parameters specified as nested elements</h3>
84<h4>map</h4>
85<p>Specifies the mapping of path prefixes between Unix and Windows.</p>
86<table border="1" cellpadding="2" cellspacing="0">
87 <tr>
88 <td valign="top"><b>Attribute</b></td>
89 <td valign="top"><b>Description</b></td>
90 <td align="center" valign="top"><b>Required</b></td>
91 </tr>
92 <tr>
93 <td valign="top">from</td>
94 <td valign="top">The prefix to match. Note that this value is case-insensitive when
95 the build is running on a Windows platform and case-sensitive when running on a
96 Unix platform.</td>
97 <td valign="top" align="center">Yes</td>
98 </tr>
99 <tr>
100 <td valign="top">to</td>
101 <td valign="top">The replacement text to use when <code>from</code> is matched.</td>
102 <td valign="top" align="center">Yes</td>
103 </tr>
104</table>
105
106<p>Each map element specifies a single replacement map to be applied to the elements of
107 the path being processed. If no map entries are specified, then no path prefix mapping
108 is performed.
109</p>
110<p><strong>Note</strong>: The map elements are applied in the order specified,
111and only the first matching map element is applied. So, the ordering of
112your map elements can be important, if any <code>from</code> values are
113prefixes of other <code>from</code> values.</i>
114</p>
115<h4>path</h4>
116<p>If the <code>refid</code> attribute is not specified, then a
117 nested <code>&lt;path&gt;</code> element must be supplied. See
118 <a href="../using.html#path">Path-like Structures</a> for details.</p>
119<h4>mapper</h4>
120<p>A single nested <a href="../CoreTypes/mapper.html">
121<code>&lt;mapper&gt;</code></a> element can be specified
122to perform any of various filename transformations (since Ant 1.6.2).
123</p>
124
125<h3>Examples</h3>
126<p>In the examples below, assume that the <code>${wl.home}</code> property
127has the value
128<code>d:\weblogic</code>, and <code>${wl.home.unix}</code> has the value
129<code>/weblogic</code>.</p>
130<h4>Example 1</h4>
131<pre>
132 &lt;path id="wl.path"&gt;
133 &lt;pathelement location=&quot;${wl.home}/lib/weblogicaux.jar&quot;/&gt;
134 &lt;pathelement location=&quot;${wl.home}/classes&quot;/&gt;
135 &lt;pathelement location=&quot;${wl.home}/mssqlserver4/classes&quot;/&gt;
136 &lt;pathelement location=&quot;c:\winnt\System32&quot;/&gt;
137 &lt;/path&gt;
138
139 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;wl.path.unix&quot; refid=&quot;wl.path&quot;&gt;
140 &lt;map from=&quot;${wl.home}&quot; to=&quot;${wl.home.unix}&quot;/&gt;
141 &lt;map from=&quot;c:&quot; to=&quot;&quot;/&gt;
142 &lt;/pathconvert&gt;
143</pre>
144<p> will generate the path shown below
145and store it in the property named <code>wl.path.unix</code>.
146</p>
147<pre>
148/weblogic/lib/weblogicaux.jar:/weblogic/classes:/weblogic/mssqlserver4/classes:/WINNT/SYSTEM32
149</pre>
150
151<h4>Example 2</h4>
152Given a FileList defined as:
153<pre>
154 &lt;filelist id=&quot;custom_tasks.jars&quot;
155 dir=&quot;${env.HOME}/ant/lib&quot;
156 files=&quot;njavac.jar,xproperty.jar&quot;/&gt;
157</pre>
158then:
159<pre>
160 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;custom_tasks.jars&quot; refid=&quot;custom_tasks.jars&quot;&gt;
161 &lt;map from=&quot;${env.HOME}&quot; to=&quot;/usr/local&quot;/&gt;
162 &lt;/pathconvert&gt;
163</pre>
164will convert the list of files to the following Unix path:
165<pre>
166/usr/local/ant/lib/njavac.jar:/usr/local/ant/lib/xproperty.jar
167</pre>
168
169<h4>Example 3</h4>
170<pre>
171 &lt;fileset dir=&quot;${src.dir}&quot; id=&quot;src.files&quot;&gt;
172 &lt;include name=&quot;**/*.java&quot;/&gt;
173 &lt;/fileset&gt;
174
175 &lt;pathconvert pathsep=&quot;,&quot; property=&quot;javafiles&quot; refid=&quot;src.files&quot;/&gt;
176</pre>
177<p>This example takes the set of files determined by the fileset (all files ending
178in <tt>.java</tt>), joins them together separated by commas, and places the resulting
179list into the property <tt>javafiles</tt>. The directory separator is not specified, so
180it defaults to the appropriate character for the current platform. Such a list could
181then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
182list of files.
183</p>
184
185<hr>
186<p align="center">Copyright &copy; 2001-2005 The Apache Software Foundation.
187All rights Reserved.</p>
188</body>
189</html>
190
191
Note: See TracBrowser for help on using the repository browser.