source: release-kits/lirk3/bin/ant-installer/web/manual1.6.2/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.1 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="foreach">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">
45 Yes, unless <code>pathsep</code> and/or
46 <code>dirsep</code> are specified.
47 </td>
48 </tr>
49 <tr>
50 <td valign="top">dirsep</td>
51 <td valign="top">
52 The character(s) to use as the directory separator in the
53 generated paths.
54 </td>
55 <td valign="top" align="center">No, defaults to current JVM <tt>File.separator</tt></td>
56 </tr>
57 <tr>
58 <td valign="top">pathsep</td>
59 <td valign="top">
60 The character(s) to use as the path-element separator in the
61 generated paths.
62 </td>
63 <td valign="top" align="center">No, defaults to current JVM <tt>File.pathSeparator</tt></td>
64 </tr>
65 <tr>
66 <td valign="top">property</td>
67 <td valign="top">The name of the property in which to place the converted path.</td>
68 <td valign="top" align="center">Yes</td>
69 </tr>
70 <tr>
71 <td valign="top">refid</td>
72 <td valign="top">What to convert, given as a
73 <a href="../using.html#references">reference</a> to a
74 <code>&lt;path&gt;</code>, <code>&lt;fileset&gt;</code>,
75 <code>&lt;dirset&gt;</code>, or <code>&lt;filelist&gt;</code>
76 defined elsewhere</td>
77 <td valign="top" align="center">No; if omitted, a nested
78 <code>&lt;path&gt;</code> element must be supplied.</td>
79 </tr>
80 <td valign="top">setonempty</td>
81 <td valign="top">Should the property be set, even if the result
82 is the empty string?
83 <td valign="top" align="center">No; default is &quot;true&quot;.
84 </tr>
85</table>
86<h3>Parameters specified as nested elements</h3>
87<h4>map</h4>
88<p>Specifies the mapping of path prefixes between Unix and Windows.</p>
89<table border="1" cellpadding="2" cellspacing="0">
90 <tr>
91 <td valign="top"><b>Attribute</b></td>
92 <td valign="top"><b>Description</b></td>
93 <td align="center" valign="top"><b>Required</b></td>
94 </tr>
95 <tr>
96 <td valign="top">from</td>
97 <td valign="top">The prefix to match. Note that this value is case-insensitive when
98 the build is running on a Windows platform and case-sensitive when running on a
99 Unix platform.</td>
100 <td valign="top" align="center">Yes</td>
101 </tr>
102 <tr>
103 <td valign="top">to</td>
104 <td valign="top">The replacement text to use when <code>from</code> is matched.</td>
105 <td valign="top" align="center">Yes</td>
106 </tr>
107</table>
108
109<p>Each map element specifies a single replacement map to be applied to the elements of
110 the path being processed. If no map entries are specified, then no path prefix mapping
111 is performed.
112</p>
113<p><strong>Note</strong>: The map elements are applied in the order specified,
114and only the first matching map element is applied. So, the ordering of
115your map elements can be important, if any <code>from</code> values are
116prefixes of other <code>from</code> values.</i>
117</p>
118<h4>path</h4>
119<p>If the <code>refid</code> attribute is not specified, then a
120 nested <code>&lt;path&gt;</code> element must be supplied. See
121 <a href="../using.html#path">Path-like Structures</a> for details.</p>
122<h4>mapper</h4>
123<p>A single nested <a href="../CoreTypes/mapper.html">
124<code>&lt;mapper&gt;</code></a> element can be specified
125to perform any of various filename transformations (since Ant 1.6.2).
126</p>
127
128<h3>Examples</h3>
129<p>In the examples below, assume that the <code>${wl.home}</code> property
130has the value
131<code>d:\weblogic</code>, and <code>${wl.home.unix}</code> has the value
132<code>/weblogic</code>.</p>
133<h4>Example 1</h4>
134<pre>
135 &lt;path id="wl.path"&gt;
136 &lt;pathelement location=&quot;${wl.home}/lib/weblogicaux.jar&quot;/&gt;
137 &lt;pathelement location=&quot;${wl.home}/classes&quot;/&gt;
138 &lt;pathelement location=&quot;${wl.home}/mssqlserver4/classes&quot;/&gt;
139 &lt;pathelement location=&quot;c:\winnt\System32&quot;/&gt;
140 &lt;/path&gt;
141
142 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;wl.path.unix&quot; refid=&quot;wl.path&quot;&gt;
143 &lt;map from=&quot;${wl.home}&quot; to=&quot;${wl.home.unix}&quot;/&gt;
144 &lt;map from=&quot;c:&quot; to=&quot;&quot;/&gt;
145 &lt;/pathconvert&gt;
146</pre>
147<p> will generate the path shown below
148and store it in the property named <code>wl.path.unix</code>.
149</p>
150<pre>
151/weblogic/lib/weblogicaux.jar:/weblogic/classes:/weblogic/mssqlserver4/classes:/WINNT/SYSTEM32
152</pre>
153
154<h4>Example 2</h4>
155Given a FileList defined as:
156<pre>
157 &lt;filelist id=&quot;custom_tasks.jars&quot;
158 dir=&quot;${env.HOME}/ant/lib&quot;
159 files=&quot;njavac.jar,xproperty.jar&quot;/&gt;
160</pre>
161then:
162<pre>
163 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;custom_tasks.jars&quot; refid=&quot;custom_tasks.jars&quot;&gt;
164 &lt;map from=&quot;${env.HOME}&quot; to=&quot;/usr/local&quot;/&gt;
165 &lt;/pathconvert&gt;
166</pre>
167will convert the list of files to the following Unix path:
168<pre>
169/usr/local/ant/lib/njavac.jar:/usr/local/ant/lib/xproperty.jar
170</pre>
171
172<h4>Example 3</h4>
173<pre>
174 &lt;fileset dir=&quot;${src.dir}&quot; id=&quot;src.files&quot;&gt;
175 &lt;include name=&quot;**/*.java&quot;/&gt;
176 &lt;/fileset&gt;
177
178 &lt;pathconvert pathsep=&quot;,&quot; property=&quot;javafiles&quot; refid=&quot;src.files&quot;/&gt;
179</pre>
180<p>This example takes the set of files determined by the fileset (all files ending
181in <tt>.java</tt>), joins them together separated by commas, and places the resulting
182list into the property <tt>javafiles</tt>. The directory separator is not specified, so
183it defaults to the appropriate character for the current platform. Such a list could
184then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
185list of files.
186</p>
187
188<hr>
189<p align="center">Copyright &copy; 2001-2004 The Apache Software Foundation.
190All rights Reserved.</p>
191</body>
192</html>
193
194
Note: See TracBrowser for help on using the repository browser.