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><path></code> or reference to a Path,
|
---|
14 | FileSet, DirSet, or FileList into a path
|
---|
15 | form for a particular platform, and stores the result in a given property.
|
---|
16 | It can also be used when you need
|
---|
17 | to convert a Path, FileSet, or DirSet into a list, separated by a given
|
---|
18 | character, such as a comma or space, or, conversely, to convert a list
|
---|
19 | of files in a FileList into a path.
|
---|
20 | </p>
|
---|
21 | <p>Nested <code><map></code> elements can be specified to map Windows
|
---|
22 | drive 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><mapper></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><path></code>, <code><fileset></code>,
|
---|
72 | <code><dirset></code>, or <code><filelist></code>
|
---|
73 | defined elsewhere</td>
|
---|
74 | <td valign="top" align="center">No; if omitted, a nested
|
---|
75 | <code><path></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 "true".
|
---|
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,
|
---|
111 | and only the first matching map element is applied. So, the ordering of
|
---|
112 | your map elements can be important, if any <code>from</code> values are
|
---|
113 | prefixes 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><path></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><mapper></code></a> element can be specified
|
---|
122 | to 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
|
---|
127 | has 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 | <path id="wl.path">
|
---|
133 | <pathelement location="${wl.home}/lib/weblogicaux.jar"/>
|
---|
134 | <pathelement location="${wl.home}/classes"/>
|
---|
135 | <pathelement location="${wl.home}/mssqlserver4/classes"/>
|
---|
136 | <pathelement location="c:\winnt\System32"/>
|
---|
137 | </path>
|
---|
138 |
|
---|
139 | <pathconvert targetos="unix" property="wl.path.unix" refid="wl.path">
|
---|
140 | <map from="${wl.home}" to="${wl.home.unix}"/>
|
---|
141 | <map from="c:" to=""/>
|
---|
142 | </pathconvert>
|
---|
143 | </pre>
|
---|
144 | <p> will generate the path shown below
|
---|
145 | and 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>
|
---|
152 | Given a FileList defined as:
|
---|
153 | <pre>
|
---|
154 | <filelist id="custom_tasks.jars"
|
---|
155 | dir="${env.HOME}/ant/lib"
|
---|
156 | files="njavac.jar,xproperty.jar"/>
|
---|
157 | </pre>
|
---|
158 | then:
|
---|
159 | <pre>
|
---|
160 | <pathconvert targetos="unix" property="custom_tasks.jars" refid="custom_tasks.jars">
|
---|
161 | <map from="${env.HOME}" to="/usr/local"/>
|
---|
162 | </pathconvert>
|
---|
163 | </pre>
|
---|
164 | will 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 | <fileset dir="${src.dir}" id="src.files">
|
---|
172 | <include name="**/*.java"/>
|
---|
173 | </fileset>
|
---|
174 |
|
---|
175 | <pathconvert pathsep="," property="javafiles" refid="src.files"/>
|
---|
176 | </pre>
|
---|
177 | <p>This example takes the set of files determined by the fileset (all files ending
|
---|
178 | in <tt>.java</tt>), joins them together separated by commas, and places the resulting
|
---|
179 | list into the property <tt>javafiles</tt>. The directory separator is not specified, so
|
---|
180 | it defaults to the appropriate character for the current platform. Such a list could
|
---|
181 | then be used in another task, like <tt>javadoc</tt>, that requires a comma separated
|
---|
182 | list of files.
|
---|
183 | </p>
|
---|
184 |
|
---|
185 | <hr>
|
---|
186 | <p align="center">Copyright © 2001-2005 The Apache Software Foundation.
|
---|
187 | All rights Reserved.</p>
|
---|
188 | </body>
|
---|
189 | </html>
|
---|
190 |
|
---|
191 |
|
---|