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">
|
---|
30 | ResourceCollection</a>s, or a reference to just one, into a path
|
---|
31 | form for a particular platform, optionally storing the result into
|
---|
32 | a given property. It can also be used when you need
|
---|
33 | to convert a Resource Collection into a list, separated by a given
|
---|
34 | character, such as a comma or space, or, conversely, e.g. to convert a list
|
---|
35 | of files in a FileList into a path.
|
---|
36 | </p>
|
---|
37 | <p>Nested <code><map></code> elements can be specified to map Windows
|
---|
38 | drive 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><mapper></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><path></code>, <code><fileset></code>,
|
---|
88 | <code><dirset></code>, or <code><filelist></code>
|
---|
89 | defined elsewhere</td>
|
---|
90 | <td valign="top" align="center">No; if omitted, a nested
|
---|
91 | <code><path></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 "true".
|
---|
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,
|
---|
131 | and only the first matching map element is applied. So, the ordering of
|
---|
132 | your map elements can be important, if any <code>from</code> values are
|
---|
133 | prefixes 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
|
---|
138 | Collection</a>s must be supplied.</p>
|
---|
139 | <h4>mapper</h4>
|
---|
140 | <p>A single nested <a href="../CoreTypes/mapper.html">
|
---|
141 | <code><mapper></code></a> element can be specified
|
---|
142 | to 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
|
---|
147 | has 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 | <path id="wl.path">
|
---|
153 | <pathelement location="${wl.home}/lib/weblogicaux.jar"/>
|
---|
154 | <pathelement location="${wl.home}/classes"/>
|
---|
155 | <pathelement location="${wl.home}/mssqlserver4/classes"/>
|
---|
156 | <pathelement location="c:\winnt\System32"/>
|
---|
157 | </path>
|
---|
158 |
|
---|
159 | <pathconvert targetos="unix" property="wl.path.unix" refid="wl.path">
|
---|
160 | <map from="${wl.home}" to="${wl.home.unix}"/>
|
---|
161 | <map from="c:" to=""/>
|
---|
162 | </pathconvert>
|
---|
163 | </pre>
|
---|
164 | <p> will generate the path shown below
|
---|
165 | and 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>
|
---|
172 | Given a FileList defined as:
|
---|
173 | <pre>
|
---|
174 | <filelist id="custom_tasks.jars"
|
---|
175 | dir="${env.HOME}/ant/lib"
|
---|
176 | files="njavac.jar,xproperty.jar"/>
|
---|
177 | </pre>
|
---|
178 | then:
|
---|
179 | <pre>
|
---|
180 | <pathconvert targetos="unix" property="custom_tasks.jars" refid="custom_tasks.jars">
|
---|
181 | <map from="${env.HOME}" to="/usr/local"/>
|
---|
182 | </pathconvert>
|
---|
183 | </pre>
|
---|
184 | will 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 | <fileset dir="${src.dir}" id="src.files">
|
---|
192 | <include name="**/*.java"/>
|
---|
193 | </fileset>
|
---|
194 |
|
---|
195 | <pathconvert pathsep="," property="javafiles" refid="src.files"/>
|
---|
196 | </pre>
|
---|
197 | <p>This example takes the set of files determined by the fileset (all files ending
|
---|
198 | in <tt>.java</tt>), joins them together separated by commas, and places the resulting
|
---|
199 | list into the property <tt>javafiles</tt>. The directory separator is not specified, so
|
---|
200 | it defaults to the appropriate character for the current platform. Such a list could
|
---|
201 | then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
|
---|
202 | list of files.
|
---|
203 | </p>
|
---|
204 | <h4>Example 4</h4>
|
---|
205 | <pre>
|
---|
206 | <pathconvert property="prop" dirsep="|">
|
---|
207 | <map from="${basedir}/abc/" to=''/>
|
---|
208 | <path location="abc/def/ghi"/>
|
---|
209 | </pathconvert>
|
---|
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 |
|
---|