source: release-kits/lirk3/bin/ant-installer/web/manual1.7.0/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: 8.2 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>PathConvert Task</title>
23</head>
24
25<body>
26
27<h2><a name="pathconvert">Pathconvert</a></h2>
28<h3>Description</h3>
29<p>Converts nested <a href="../CoreTypes/resources.html#collection">
30ResourceCollection</a>s, or a reference to just one, into a path
31form for a particular platform, optionally storing the result into
32a given property. It can also be used when you need
33to convert a Resource Collection into a list, separated by a given
34character, such as a comma or space, or, conversely, e.g. to convert a list
35of files in a FileList into a path.
36</p>
37<p>Nested <code>&lt;map&gt;</code> elements can be specified to map Windows
38drive letters to Unix paths, and vice-versa.</p>
39<p>More complex transformations can be achieved using a nested
40<a href="../CoreTypes/mapper.html"><code>&lt;mapper&gt;</code></a>
41(since Ant 1.6.2).
42</p>
43
44<h3>Parameters</h3>
45<table border="1" cellpadding="2" cellspacing="0">
46 <tr>
47 <td valign="top"><b>Attribute</b></td>
48 <td valign="top"><b>Description</b></td>
49 <td align="center" valign="top"><b>Required</b></td>
50 </tr>
51 <tr>
52 <td valign="top">targetos</td>
53 <td valign="top">
54 The target architecture. Must be one of 'unix', 'windows',
55 'netware', 'tandem' or 'os/2'.
56 This is a shorthand mechanism for specifying both
57 <code>pathsep</code> and <code>dirsep</code>
58 according to the specified target architecture.
59 </td>
60 <td valign="top" align="center">No</td>
61 </tr>
62 <tr>
63 <td valign="top">dirsep</td>
64 <td valign="top">
65 The character(s) to use as the directory separator in the
66 generated paths.
67 </td>
68 <td valign="top" align="center">No, defaults to current JVM <tt>File.separator</tt></td>
69 </tr>
70 <tr>
71 <td valign="top">pathsep</td>
72 <td valign="top">
73 The character(s) to use as the path-element separator in the
74 generated paths.
75 </td>
76 <td valign="top" align="center">No, defaults to current JVM <tt>File.pathSeparator</tt></td>
77 </tr>
78 <tr>
79 <td valign="top">property</td>
80 <td valign="top">The name of the property in which to place the converted path.</td>
81 <td valign="top" align="center">No, result will be logged if unset</td>
82 </tr>
83 <tr>
84 <td valign="top">refid</td>
85 <td valign="top">What to convert, given as a
86 <a href="../using.html#references">reference</a> to a
87 <code>&lt;path&gt;</code>, <code>&lt;fileset&gt;</code>,
88 <code>&lt;dirset&gt;</code>, or <code>&lt;filelist&gt;</code>
89 defined elsewhere</td>
90 <td valign="top" align="center">No; if omitted, a nested
91 <code>&lt;path&gt;</code> element must be supplied.</td>
92 </tr>
93 <td valign="top">setonempty</td>
94 <td valign="top">Should the property be set, even if the result
95 is the empty string?
96 <td valign="top" align="center">No; default is &quot;true&quot;.
97 </tr>
98</table>
99<h3>Parameters specified as nested elements</h3>
100<h4>map</h4>
101<p>Specifies the mapping of path prefixes between Unix and Windows.</p>
102<table border="1" cellpadding="2" cellspacing="0">
103 <tr>
104 <td valign="top"><b>Attribute</b></td>
105 <td valign="top"><b>Description</b></td>
106 <td align="center" valign="top"><b>Required</b></td>
107 </tr>
108 <tr>
109 <td valign="top">from</td>
110 <td valign="top">
111 The prefix to match. Note that this value is case-insensitive when
112 the build is running on a Windows platform and case-sensitive
113 when running on a Unix platform.
114 <em>Since Ant 1.7.0</em>, on Windows this value is also insensitive
115 to the slash style used for directories, one can use '/' or '\'.
116 </td>
117 <td valign="top" align="center">Yes</td>
118 </tr>
119 <tr>
120 <td valign="top">to</td>
121 <td valign="top">The replacement text to use when <code>from</code> is matched.</td>
122 <td valign="top" align="center">Yes</td>
123 </tr>
124</table>
125
126<p>Each map element specifies a single replacement map to be applied to the elements of
127 the path being processed. If no map entries are specified, then no path prefix mapping
128 is performed.
129</p>
130<p><strong>Note</strong>: The map elements are applied in the order specified,
131and only the first matching map element is applied. So, the ordering of
132your map elements can be important, if any <code>from</code> values are
133prefixes of other <code>from</code> values.</i>
134</p>
135<h4>Resource Collections</h4>
136<p>If the <code>refid</code> attribute is not specified, then one or more
137 nested <a href="../CoreTypes/resources.html#collection">Resource
138Collection</a>s must be supplied.</p>
139<h4>mapper</h4>
140<p>A single nested <a href="../CoreTypes/mapper.html">
141<code>&lt;mapper&gt;</code></a> element can be specified
142to perform any of various filename transformations (since Ant 1.6.2).
143</p>
144
145<h3>Examples</h3>
146<p>In the examples below, assume that the <code>${wl.home}</code> property
147has the value
148<code>d:\weblogic</code>, and <code>${wl.home.unix}</code> has the value
149<code>/weblogic</code>.</p>
150<h4>Example 1</h4>
151<pre>
152 &lt;path id="wl.path"&gt;
153 &lt;pathelement location=&quot;${wl.home}/lib/weblogicaux.jar&quot;/&gt;
154 &lt;pathelement location=&quot;${wl.home}/classes&quot;/&gt;
155 &lt;pathelement location=&quot;${wl.home}/mssqlserver4/classes&quot;/&gt;
156 &lt;pathelement location=&quot;c:\winnt\System32&quot;/&gt;
157 &lt;/path&gt;
158
159 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;wl.path.unix&quot; refid=&quot;wl.path&quot;&gt;
160 &lt;map from=&quot;${wl.home}&quot; to=&quot;${wl.home.unix}&quot;/&gt;
161 &lt;map from=&quot;c:&quot; to=&quot;&quot;/&gt;
162 &lt;/pathconvert&gt;
163</pre>
164<p> will generate the path shown below
165and store it in the property named <code>wl.path.unix</code>.
166</p>
167<pre>
168/weblogic/lib/weblogicaux.jar:/weblogic/classes:/weblogic/mssqlserver4/classes:/WINNT/SYSTEM32
169</pre>
170
171<h4>Example 2</h4>
172Given a FileList defined as:
173<pre>
174 &lt;filelist id=&quot;custom_tasks.jars&quot;
175 dir=&quot;${env.HOME}/ant/lib&quot;
176 files=&quot;njavac.jar,xproperty.jar&quot;/&gt;
177</pre>
178then:
179<pre>
180 &lt;pathconvert targetos=&quot;unix&quot; property=&quot;custom_tasks.jars&quot; refid=&quot;custom_tasks.jars&quot;&gt;
181 &lt;map from=&quot;${env.HOME}&quot; to=&quot;/usr/local&quot;/&gt;
182 &lt;/pathconvert&gt;
183</pre>
184will convert the list of files to the following Unix path:
185<pre>
186/usr/local/ant/lib/njavac.jar:/usr/local/ant/lib/xproperty.jar
187</pre>
188
189<h4>Example 3</h4>
190<pre>
191 &lt;fileset dir=&quot;${src.dir}&quot; id=&quot;src.files&quot;&gt;
192 &lt;include name=&quot;**/*.java&quot;/&gt;
193 &lt;/fileset&gt;
194
195 &lt;pathconvert pathsep=&quot;,&quot; property=&quot;javafiles&quot; refid=&quot;src.files&quot;/&gt;
196</pre>
197<p>This example takes the set of files determined by the fileset (all files ending
198in <tt>.java</tt>), joins them together separated by commas, and places the resulting
199list into the property <tt>javafiles</tt>. The directory separator is not specified, so
200it defaults to the appropriate character for the current platform. Such a list could
201then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
202list of files.
203</p>
204<h4>Example 4</h4>
205<pre>
206 &lt;pathconvert property="prop" dirsep="|"&gt;
207 &lt;map from="${basedir}/abc/" to=''/&gt;
208 &lt;path location="abc/def/ghi"/&gt;
209 &lt;/pathconvert&gt;
210</pre>
211 <p>
212 This example sets the property "prop" to "def|ghi" on
213 Windows and on Unix.
214 </p>
215</body>
216</html>
217
218
Note: See TracBrowser for help on using the repository browser.