source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/docs/manual/CoreTypes/mapper.html@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 24.7 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Mapper Type</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="mapper">Mapping File Names</a></h2>
12<p>Some tasks take source files and create target files. Depending on
13the task, it may be quite obvious which name a target file will have
14(using <a href="../CoreTasks/javac.html">javac</a>, you know there will be
15<code>.class</code> files for your <code>.java</code> files) - in
16other cases you may want to specify the target files, either to help
17Ant or to get an extra bit of functionality.</p>
18<p>While source files are usually specified as <a
19href="fileset.html">fileset</a>s, you don't specify target files directly -
20instead, you tell Ant how to find the target file(s) for one source file. An
21instance of <code>org.apache.tools.ant.util.FileNameMapper</code> is
22responsible for this. It constructs target file names based on rules
23that can be parameterized with <code>from</code> and <code>to</code>
24attributes - the exact meaning of which is implementation-dependent.</p>
25<p>These instances are defined in <code>&lt;mapper&gt;</code> elements
26with the following attributes:</p>
27<table border="1" cellpadding="2" cellspacing="0">
28 <tr>
29 <td valign="top"><b>Attribute</b></td>
30 <td valign="top"><b>Description</b></td>
31 <td align="center" valign="top"><b>Required</b></td>
32 </tr>
33 <tr>
34 <td valign="top">type</td>
35 <td valign="top">specifies one of the built-in implementations.</td>
36 <td rowspan="2" align="center" valign="middle">Exactly one of these</td>
37 </tr>
38 <tr>
39 <td valign="top">classname</td>
40 <td valign="top">specifies the implementation by class name.</td>
41 </tr>
42 <tr>
43 <td valign="top">classpath</td>
44 <td valign="top">the classpath to use when looking up
45 <code>classname</code>.</td>
46 <td align="center" valign="top">No</td>
47 </tr>
48 <tr>
49 <td valign="top">classpathref</td>
50 <td valign="top">the classpath to use, given as <a
51 href="../using.html#references">reference</a> to a path defined elsewhere.</td>
52 <td align="center" valign="top">No</td>
53 </tr>
54 <tr>
55 <td valign="top">from</td>
56 <td valign="top">the <code>from</code> attribute for the given
57 implementation.</td>
58 <td align="center" valign="top">Depends on implementation.</td>
59 </tr>
60 <tr>
61 <td valign="top">to</td>
62 <td valign="top">the <code>to</code> attribute for the given
63 implementation.</td>
64 <td align="center" valign="top">Depends on implementation.</td>
65 </tr>
66</table>
67<p>Note that Ant will not automatically convert / or \ characters in
68the <code>to</code> and <code>from</code> attributes to the correct
69directory separator of your current platform. If you need to specify
70this separator, use <code>${file.separator}</code> instead.
71 For the regexpmapper, <code>${file.separator}</code> will not work,
72as on windows it is the '\' character, and this is an escape character
73for regular expressions, one should use the <code>handledirsep</code> attribute
74instead.
75</p>
76<h3>Parameters specified as nested elements</h3>
77<p>The classpath can be specified via a nested
78<code>&lt;classpath&gt;</code>, as well - that is,
79a <a href="../using.html#path">path</a>-like structure.</p>
80<p><b>Since Ant 1.6.2,</b> nested File Mappers can
81be supplied via either <CODE>&lt;mapper&gt;</CODE> elements or
82<a href="../CoreTasks/typedef.html"><code>&lt;typedef&gt;</code></a>'d
83implementations of <CODE>org.apache.tools.ant.util.FileNameMapper</CODE>.
84If nested File Mappers are specified by either means, the mapper will be
85implicitly configured as a <a href="#composite-mapper">composite mapper</a>.
86</p>
87<hr/>
88<h3>The built-in mapper types are:</h3>
89<p>All built-in mappers are case-sensitive.</p>
90<p><b>As of Ant 1.6.2,</b> each of the built-in mapper implementation
91 types is directly accessible using a specific tagname. This makes it
92 possible for filename mappers to support attributes in addition to
93 the generally available <i>to</i> and <i>from</i>.<br/>
94 The <code>&lt;mapper type|classname=&quot;...&quot;&gt;</code> usage
95 form remains valid for reasons of backward compatibility.</p>
96<h4><a name="identity-mapper">identity</a></h4>
97<p>The target file name is identical to the source file name. Both
98<code>to</code> and <code>from</code> will be ignored.</p>
99<b>Examples:</b>
100<blockquote><pre>
101&lt;mapper type=&quot;identity&quot;/&gt;
102&lt;identitymapper/&gt;
103</pre></blockquote>
104<table border="1" cellpadding="2" cellspacing="0">
105 <tr>
106 <td valign="top"><b>Source file name</b></td>
107 <td valign="top"><b>Target file name</b></td>
108 </tr>
109 <tr>
110 <td valign="top"><code>A.java</code></td>
111 <td valign="top"><code>A.java</code></td>
112 </tr>
113 <tr>
114 <td valign="top"><code>foo/bar/B.java</code></td>
115 <td valign="top"><code>foo/bar/B.java</code></td>
116 </tr>
117 <tr>
118 <td valign="top"><code>C.properties</code></td>
119 <td valign="top"><code>C.properties</code></td>
120 </tr>
121 <tr>
122 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
123 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
124 </tr>
125</table>
126<h4><a name="flatten-mapper">flatten</a></h4>
127<p>The target file name is identical to the source file name, with all
128leading directory information stripped off. Both <code>to</code> and
129<code>from</code> will be ignored.</p>
130<b>Examples:</b>
131<blockquote><pre>
132&lt;mapper type=&quot;flatten&quot;/&gt;
133&lt;flattenmapper/&gt;
134</pre></blockquote>
135<table border="1" cellpadding="2" cellspacing="0">
136 <tr>
137 <td valign="top"><b>Source file name</b></td>
138 <td valign="top"><b>Target file name</b></td>
139 </tr>
140 <tr>
141 <td valign="top"><code>A.java</code></td>
142 <td valign="top"><code>A.java</code></td>
143 </tr>
144 <tr>
145 <td valign="top"><code>foo/bar/B.java</code></td>
146 <td valign="top"><code>B.java</code></td>
147 </tr>
148 <tr>
149 <td valign="top"><code>C.properties</code></td>
150 <td valign="top"><code>C.properties</code></td>
151 </tr>
152 <tr>
153 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
154 <td valign="top"><code>A.properties</code></td>
155 </tr>
156</table>
157<h4><a name="merge-mapper">merge</a></h4>
158<p>The target file name will always be the same, as defined by
159<code>to</code> - <code>from</code> will be ignored.</p>
160<h5>Examples:</h5>
161<blockquote><pre>
162&lt;mapper type=&quot;merge&quot; to=&quot;archive.tar&quot;/&gt;
163&lt;mergemapper to=&quot;archive.tar&quot;/&gt;
164</pre></blockquote>
165<table border="1" cellpadding="2" cellspacing="0">
166 <tr>
167 <td valign="top"><b>Source file name</b></td>
168 <td valign="top"><b>Target file name</b></td>
169 </tr>
170 <tr>
171 <td valign="top"><code>A.java</code></td>
172 <td valign="top"><code>archive.tar</code></td>
173 </tr>
174 <tr>
175 <td valign="top"><code>foo/bar/B.java</code></td>
176 <td valign="top"><code>archive.tar</code></td>
177 </tr>
178 <tr>
179 <td valign="top"><code>C.properties</code></td>
180 <td valign="top"><code>archive.tar</code></td>
181 </tr>
182 <tr>
183 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
184 <td valign="top"><code>archive.tar</code></td>
185 </tr>
186</table>
187<h4><a name="glob-mapper">glob</a></h4>
188<p>Both <code>to</code> and <code>from</code> define patterns that may
189contain at most one <code>*</code>. For each source file that matches
190the <code>from</code> pattern, a target file name will be constructed
191from the <code>to</code> pattern by substituting the <code>*</code> in
192the <code>to</code> pattern with the text that matches the
193<code>*</code> in the <code>from</code> pattern. Source file names
194that don't match the <code>from</code> pattern will be ignored.</p>
195<b>Examples:</b>
196<blockquote><pre>
197&lt;mapper type=&quot;glob&quot; from=&quot;*.java&quot; to=&quot;*.java.bak&quot;/&gt;
198&lt;globmapper from=&quot;*.java&quot; to=&quot;*.java.bak&quot;/&gt;
199</pre></blockquote>
200<table border="1" cellpadding="2" cellspacing="0">
201 <tr>
202 <td valign="top"><b>Source file name</b></td>
203 <td valign="top"><b>Target file name</b></td>
204 </tr>
205 <tr>
206 <td valign="top"><code>A.java</code></td>
207 <td valign="top"><code>A.java.bak</code></td>
208 </tr>
209 <tr>
210 <td valign="top"><code>foo/bar/B.java</code></td>
211 <td valign="top"><code>foo/bar/B.java.bak</code></td>
212 </tr>
213 <tr>
214 <td valign="top"><code>C.properties</code></td>
215 <td valign="top">ignored</td>
216 </tr>
217 <tr>
218 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
219 <td valign="top">ignored</td>
220 </tr>
221</table>
222<blockquote><pre>
223&lt;mapper type=&quot;glob&quot; from=&quot;C*ies&quot; to=&quot;Q*y&quot;/&gt;
224&lt;globmapper from=&quot;C*ies&quot; to=&quot;Q*y&quot;/&gt;
225</pre></blockquote>
226<table border="1" cellpadding="2" cellspacing="0">
227 <tr>
228 <td valign="top"><b>Source file name</b></td>
229 <td valign="top"><b>Target file name</b></td>
230 </tr>
231 <tr>
232 <td valign="top"><code>A.java</code></td>
233 <td valign="top">ignored</td>
234 </tr>
235 <tr>
236 <td valign="top"><code>foo/bar/B.java</code></td>
237 <td valign="top">ignored</td>
238 </tr>
239 <tr>
240 <td valign="top"><code>C.properties</code></td>
241 <td valign="top"><code>Q.property</code></td>
242 </tr>
243 <tr>
244 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
245 <td valign="top"><code>Qlasses/dir/dir2/A.property</code></td>
246 </tr>
247</table>
248 <p>
249 The globmapper mapper can take the following extra attributes.
250 </p>
251 <table border="1" cellpadding="2" cellspacing="0">
252 <tr>
253 <td valign="top"><b>Attribute</b></td>
254 <td valign="top"><b>Description</b></td>
255 <td align="center" valign="top"><b>Required</b></td>
256 </tr>
257 <tr>
258 <td valign="top">casesensitive</td>
259 <td valign="top">
260 If this is false, the mapper will ignore case when matching the glob pattern.
261 This attribute can be true or false, the default is true.
262 <em>Since ant 1.6.3.</em>
263 </td>
264 <td align="center" valign="top">No</td>
265 </tr>
266 <tr>
267 <td valign="top">handledirsep</td>
268 <td valign="top">
269 If this is specified, the mapper will ignore the difference between the normal
270 directory separator characters - \ and /.
271 This attribute can be true or false, the default is false.
272 This attribute is useful for cross-platform build files.
273 <em>Since ant 1.6.3.</em>
274 <td align="center" valign="top">No</td>
275 </tr>
276 </table>
277 <p>
278 An example:
279 </p>
280 <pre>
281 &lt;pathconvert property="x" targetos="unix"&gt;
282 &lt;path path="Aj.Java"/&gt;
283 &lt;mapper&gt;
284 &lt;chainedmapper&gt;
285 &lt;flattenmapper/&gt;
286 &lt;globmapper from="a*.java" to="*.java.bak" casesensitive="no"/&gt;
287 &lt;/chainedmapper&gt;
288 &lt;/mapper&gt;
289 &lt;/pathconvert&gt;
290 &lt;echo&gt;x is ${x}&lt;/echo&gt;
291 </pre>
292 <p>
293 will output "x is j.java.bak".
294 </p>
295 <p>
296 and
297 </p>
298 <pre>
299 &lt;pathconvert property="x" targetos="unix"&gt;
300 &lt;path path="d/e/f/j.java"/&gt;
301 &lt;mapper&gt;
302 &lt;globmapper from="${basedir}\d/e\*" to="*" ignoredirchar="yes"/&gt;
303 &lt;/mapper&gt;
304 &lt;/pathconvert&gt;
305 &lt;echo&gt;x is ${x}&lt;/echo&gt;
306 </pre>
307 <p>
308 will output "x is f/j.java".
309 </p>
310
311<h4><a name="regexp-mapper">regexp</a></h4>
312<p>Both <code>to</code> and <code>from</code> define regular
313expressions. If the source file name matches the <code>from</code>
314pattern, the target file name will be constructed from the
315<code>to</code> pattern, using <code>\0</code> to <code>\9</code> as
316back-references for the full
317match (<code>\0</code>) or the matches of the subexpressions in
318parentheses.
319Source
320files not matching the <code>from</code> pattern will be ignored.</p>
321<p>Note that you need to escape a dollar-sign (<code>$</code>) with
322another dollar-sign in Ant.</p>
323<p>The regexp mapper needs a supporting library and an implementation
324of <code>org.apache.tools.ant.util.regexp.RegexpMatcher</code> that
325hides the specifics of the library. Ant comes with implementations for
326<a href="http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary.html" target="_top">the java.util.regex package of JDK 1.4 or higher</a>,
327<a href="http://jakarta.apache.org/regexp/" target="_top">jakarta-regexp</a> and <a
328href="http://jakarta.apache.org/oro/" target="_top">jakarta-ORO</a>. If you compile
329from sources and plan to use one of them, make sure the libraries are
330in your <code>CLASSPATH</code>. For information about using <a
331href="http://www.cacas.org/~wes/java/" target="_top">gnu.regexp</a> or <a
332href="http://www.crocodile.org/~sts/Rex/" target="_top">gnu.rex</a> with Ant, see <a
333href="http://marc.theaimsgroup.com/?l=ant-dev&m=97550753813481&w=2" target="_top">this</a>
334article.</p>
335<p>This means, you need one of the supported regular expression
336 libraries <strong>and</strong>
337 the corresponding <code>ant-[jakarta-oro, jakarta-regexp, apache-oro, apache-regexp}.jar</code>
338from the Ant release you are using.
339Make sure, both will be loaded from the same
340classpath, that is either put them into your <code>CLASSPATH</code>,
341<code>ANT_HOME/lib</code> directory or a nested
342<code>&lt;classpath&gt;</code> element of the mapper - you cannot have
343<code>ant-[jakarta-oro, jakarta-regexp, apache-oro, apache-regexp].jar</code> in <code>ANT_HOME/lib</code>
344 and the library
345in a nested <code>&lt;classpath&gt;</code>.</p>
346<p>Ant will choose the regular-expression library based on the
347following algorithm:</p>
348<ul>
349<li>If the system property
350<code>ant.regexp.matcherimpl</code> has been set, it is taken as the
351name of the class implementing
352<code>org.apache.tools.ant.util.regexp.RegexpMatcher</code> that
353should be used.</li>
354<li>If it has not been set, first try the JDK 1.4 classes, then
355jakarta-ORO and finally try jakarta-regexp.</li>
356</ul>
357
358<b>Examples:</b>
359<blockquote><pre>
360&lt;mapper type=&quot;regexp&quot; from=&quot;^(.*)\.java$$&quot; to=&quot;\1.java.bak&quot;/&gt;
361&lt;regexpmapper from=&quot;^(.*)\.java$$&quot; to=&quot;\1.java.bak&quot;/&gt;
362</pre></blockquote>
363<table border="1" cellpadding="2" cellspacing="0">
364 <tr>
365 <td valign="top"><b>Source file name</b></td>
366 <td valign="top"><b>Target file name</b></td>
367 </tr>
368 <tr>
369 <td valign="top"><code>A.java</code></td>
370 <td valign="top"><code>A.java.bak</code></td>
371 </tr>
372 <tr>
373 <td valign="top"><code>foo/bar/B.java</code></td>
374 <td valign="top"><code>foo/bar/B.java.bak</code></td>
375 </tr>
376 <tr>
377 <td valign="top"><code>C.properties</code></td>
378 <td valign="top">ignored</td>
379 </tr>
380 <tr>
381 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
382 <td valign="top">ignored</td>
383 </tr>
384</table>
385<blockquote><pre>
386&lt;mapper type=&quot;regexp&quot; from=&quot;^(.*)/([^/]+)/([^/]*)$$&quot; to=&quot;\1/\2/\2-\3&quot;/&gt;
387&lt;regexpmapper from=&quot;^(.*)/([^/]+)/([^/]*)$$&quot; to=&quot;\1/\2/\2-\3&quot;/&gt;
388</pre></blockquote>
389<table border="1" cellpadding="2" cellspacing="0">
390 <tr>
391 <td valign="top"><b>Source file name</b></td>
392 <td valign="top"><b>Target file name</b></td>
393 </tr>
394 <tr>
395 <td valign="top"><code>A.java</code></td>
396 <td valign="top">ignored</td>
397 </tr>
398 <tr>
399 <td valign="top"><code>foo/bar/B.java</code></td>
400 <td valign="top"><code>foo/bar/bar-B.java</code></td>
401 </tr>
402 <tr>
403 <td valign="top"><code>C.properties</code></td>
404 <td valign="top">ignored</td>
405 </tr>
406 <tr>
407 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
408 <td valign="top"><code>Classes/dir/dir2/dir2-A.properties</code></td>
409 </tr>
410</table>
411<blockquote><pre>
412&lt;mapper type="regexp" from="^(.*)\.(.*)$$" to="\2.\1"/&gt;
413&lt;regexpmapper from="^(.*)\.(.*)$$&" to="\2.\1"/&gt;
414</pre></blockquote>
415<table border="1" cellpadding="2" cellspacing="0">
416 <tr>
417 <td valign="top"><b>Source file name</b></td>
418 <td valign="top"><b>Target file name</b></td>
419 </tr>
420 <tr>
421 <td valign="top"><code>A.java</code></td>
422 <td valign="top"><code>java.A</code></td>
423 </tr>
424 <tr>
425 <td valign="top"><code>foo/bar/B.java</code></td>
426 <td valign="top"><code>java.foo/bar/B</code></td>
427 </tr>
428 <tr>
429 <td valign="top"><code>C.properties</code></td>
430 <td valign="top"><code>properties.C</code></td>
431 </tr>
432 <tr>
433 <td valign="top"><code>Classes/dir/dir2/A.properties</code></td>
434 <td valign="top"><code>properties.Classes/dir/dir2/A</code></td>
435 </tr>
436</table>
437<blockquote><pre>
438&lt;mapper type="regexp" from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java"/&gt;
439&lt;regexpmapper from="^(.*?)(\$$[^/\\\.]*)?\.class$$" to="\1.java"/&gt;
440</pre></blockquote>
441<table border="1" cellpadding="2" cellspacing="0">
442 <tr>
443 <td valign="top"><b>Source file name</b></td>
444 <td valign="top"><b>Target file name</b></td>
445 </tr>
446 <tr>
447 <td valign="top"><code>ClassLoader.class</code></td>
448 <td valign="top"><code>ClassLoader.java</code></td>
449 </tr>
450 <tr>
451 <td valign="top"><code>java/lang/ClassLoader.class</code></td>
452 <td valign="top"><code>java/lang/ClassLoader.java</code></td>
453 </tr>
454 <tr>
455 <td valign="top"><code>java\lang\ClassLoader$1.class</code></td>
456 <td valign="top"><code>java\lang\ClassLoader.java</code></td>
457 </tr>
458 <tr>
459 <td valign="top"><code>java/lang/ClassLoader$foo$1.class</code></td>
460 <td valign="top"><code>java/lang/ClassLoader.java</code></td>
461 </tr>
462</table>
463 <p>
464 The regexpmapper mapper can take the following extra attributes.
465 </p>
466 <table border="1" cellpadding="2" cellspacing="0">
467 <tr>
468 <td valign="top"><b>Attribute</b></td>
469 <td valign="top"><b>Description</b></td>
470 <td align="center" valign="top"><b>Required</b></td>
471 </tr>
472 <tr>
473 <td valign="top">casesensitive</td>
474 <td valign="top">
475 If this is false, the mapper will ignore case when matching the pattern.
476 This attribute can be true or false, the default is true.
477 <em>Since ant 1.6.3.</em>
478 </td>
479 <td align="center" valign="top">No</td>
480 </tr>
481 <tr>
482 <td valign="top">handledirsep</td>
483 <td valign="top">
484 If this is specified, the mapper will treat a \ character in a filename
485 as a / for the purposes of matching.
486 This attribute can be true or false, the default is false.
487 This attribute is useful for cross-platform build files.
488 <em>Since ant 1.6.3.</em>
489 <td align="center" valign="top">No</td>
490 </tr>
491 </table>
492 <p>
493 An example:
494 </p>
495 <pre>
496 &lt;pathconvert property="x" targetos="unix"&gt;
497 &lt;path path="Aj.Java"/&gt;
498 &lt;chainedmapper&gt;
499 &lt;flattenmapper/&gt;
500 &lt;regexpmapper from="a(*.)java" to="\1.java.bak" casesensitive="no"/&gt;
501 &lt;/chainedmapper&gt;
502 &lt;/pathconvert&gt;
503 &lt;echo&gt;x is ${x}&lt;/echo&gt;
504 </pre>
505 <p>
506 will output "x is j.java.bak".
507 </p>
508 <p>
509 and
510 </p>
511 <pre>
512 &lt;pathconvert property="hd.prop" targetos="windows"&gt;
513 &lt;path path="d\e/f\j.java"/&gt;
514 &lt;chainedmapper&gt;
515 &lt;regexpmapper from="${basedir}/d/e/(.*)" to="\1" handledirsep="yes"/&gt;
516 &lt;/chainedmapper&gt;
517 &lt;/pathconvert&gt;
518 </pre>
519 <p>
520 will set <code>hd.prop</code> to "f\j.java".
521 </p>
522<h4><a name="package-mapper">package</a></h4>
523<p>Sharing the same syntax as the <a href="#glob-mapper">glob mapper</a>,
524the package mapper replaces
525directory separators found in the matched source pattern with dots in the target
526pattern placeholder. This mapper is particularly useful in combination
527with <code>&lt;uptodate&gt;</code> and <code>&lt;junit&gt;</code> output.</p>
528<b>Example:</b>
529<blockquote><pre>
530&lt;mapper type="package" from="*Test.java" to="TEST-*Test.xml"/&gt;
531&lt;packagemapper from="*Test.java" to="TEST-*Test.xml"/&gt;
532</pre></blockquote>
533<table border="1" cellpadding="2" cellspacing="0">
534 <tr>
535 <td valign="top"><b>Source file name</b></td>
536 <td valign="top"><b>Target file name</b></td>
537 </tr>
538 <tr>
539 <td valign="top"><code>org/apache/tools/ant/util/PackageMapperTest.java</code></td>
540 <td valign="top"><code>TEST-org.apache.tools.ant.util.PackageMapperTest.xml</code></td>
541 </tr>
542 <tr>
543 <td valign="top"><code>org/apache/tools/ant/util/Helper.java</code></td>
544 <td valign="top">ignored</td>
545 </tr>
546</table>
547<h4><a name="unpackage-mapper">unpackage (since ant 1.6.0)</a></h4>
548 <p>This mapper is the inverse of the <a href="#package-mapper">package</a> mapper.
549 It replaces the dots in a package name with directory separators. This
550 is useful for matching XML formatter results against their JUnit test
551 test cases. The mapper shares the sample syntax
552 as the <a href="#glob-mapper">glob mapper</a>.
553 </p>
554<b>Example:</b>
555<blockquote><pre>
556&lt;mapper type="unpackage" from="TEST-*Test.xml" to="${test.src.dir}/*Test.java"&gt;
557&lt;unpackagemapper from="TEST-*Test.xml" to="${test.src.dir}/*Test.java"&gt;
558</pre></blockquote>
559<table border="1" cellpadding="2" cellspacing="0">
560 <tr>
561 <td valign="top"><b>Source file name</b></td>
562 <td valign="top"><b>Target file name</b></td>
563 </tr>
564 <tr>
565 <td valign="top"><code>TEST-org.acme.AcmeTest.xml</code></td>
566 <td valign="top"><code>${test.src.dir}/org/acme/AcmeTest.java</code></td>
567 </tr>
568</table>
569<h4><a name="composite-mapper">composite (since ant 1.6.2)</a></h4>
570 <p>This mapper implementation can contain multiple nested mappers.
571 File mapping is performed by passing the source filename to each nested
572 <code>&lt;mapper&gt;</code> in turn, returning all results.
573 The <i>to</i> and <i>from</i> attributes are ignored.</p>
574<b>Examples:</b>
575<blockquote><pre>
576&lt;compositemapper&gt;
577 &lt;identitymapper/&gt;
578 &lt;packagemapper from="*.java" to="*"/&gt;
579&lt;/compositemapper&gt;
580</pre></blockquote>
581<table border="1" cellpadding="2" cellspacing="0">
582 <tr>
583 <td valign="top"><b>Source file name</b></td>
584 <td valign="top"><b>Target file names</b></td>
585 </tr>
586 <tr>
587 <td valign="center" rowspan="2"><code>foo/bar/A.java</code></td>
588 <td valign="top"><code>foo/bar/A.java</code></td>
589 </tr>
590 <tr>
591 <td valign="top"><code>foo.bar.A</code></td>
592 </tr>
593</table>
594 <p>The composite mapper has no corresponding
595 <code>&lt;mapper <b>type</b>&gt;</code> attribute.
596 </p>
597<h4><a name="chained-mapper">chained (since ant 1.6.2)</a></h4>
598 <p>This mapper implementation can contain multiple nested mappers.
599 File mapping is performed by passing the source filename to the first
600 nested mapper, its results to the second, and so on. The target filenames
601 generated by the last nested mapper comprise the ultimate results of the
602 mapping operation. The <i>to</i> and <i>from</i> attributes are ignored.</p>
603<b>Examples:</b>
604<blockquote><pre>
605&lt;chainedmapper&gt;
606 &lt;flattenmapper/&gt;
607 &lt;globmapper from="*" to="new/path/*"/&gt;
608 &lt;mapper&gt;
609 &lt;globmapper from="*" to="*1"/&gt;
610 &lt;globmapper from="*" to="*2"/&gt;
611 &lt;/mapper&gt;
612&lt;/chainedmapper&gt;
613</pre></blockquote>
614<table border="1" cellpadding="2" cellspacing="0">
615 <tr>
616 <td valign="top"><b>Source file name</b></td>
617 <td valign="top"><b>Target file names</b></td>
618 </tr>
619 <tr>
620 <td valign="center" rowspan="2"><code>foo/bar/A.java</code></td>
621 <td valign="top"><code>new/path/A.java1</code></td>
622 </tr>
623 <tr>
624 <td valign="top"><code>new/path/A.java2</code></td>
625 </tr>
626 <tr>
627 <td valign="center" rowspan="2"><code>boo/far/B.java</code></td>
628 <td valign="top"><code>new/path/B.java1</code></td>
629 </tr>
630 <tr>
631 <td valign="top"><code>new/path/B.java2</code></td>
632 </tr>
633</table>
634 <p>The chained mapper has no corresponding
635 <code>&lt;mapper <b>type</b>&gt;</code> attribute.
636 </p>
637
638 <!-- -->
639 <!-- Filter Mapper -->
640 <!-- -->
641
642<h4><a name="filter-mapper">filtermapper (since ant 1.6.3)</a></h4>
643 <p>
644 This mapper implementation applies a <a href="filterchain.html">filterchain</a>
645 to the source file name.
646 </p>
647<b>Examples:</b>
648<blockquote><pre>
649&lt;filtermapper&gt;
650 &lt;replacestring from="\" to="/"/&gt;
651&lt;/filtermapper&gt;
652</pre></blockquote>
653
654<table border="1" cellpadding="2" cellspacing="0">
655 <tr>
656 <td valign="top"><b>Source file name</b></td>
657 <td valign="top"><b>Target file names</b></td>
658 </tr>
659 <tr>
660 <td valign="center"><code>foo\bar\A.java</code></td>
661 <td valign="top"><code>foo/bar/A.java</code></td>
662 </tr>
663</table>
664<blockquote><pre>
665&lt;filtermapper&gt;
666 &lt;scriptfilter language="beanshell"&gt;
667 self.setToken(self.getToken().toUpperCase());
668 &lt;/scriptfilter&gt;
669&lt;/filtermapper&gt;
670</pre></blockquote>
671
672<table border="1" cellpadding="2" cellspacing="0">
673 <tr>
674 <td valign="top"><b>Source file name</b></td>
675 <td valign="top"><b>Target file names</b></td>
676 </tr>
677 <tr>
678 <td valign="center"><code>foo\bar\A.java</code></td>
679 <td valign="top"><code>FOO\BAR\A.JAVA</code></td>
680 </tr>
681</table>
682
683 <p>The filtermapper has no corresponding
684 <code>&lt;mapper <b>type</b>&gt;</code> attribute.
685 </p>
686<hr>
687<p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
688Reserved.</p>
689
690</body>
691</html>
Note: See TracBrowser for help on using the repository browser.