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 6.5 KiB

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