You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pathconvert.html 7.0 KiB

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