next up previous contents index
Next: Parameters specified as nested Up: Core Types Previous: FileSet   Contents   Index

File Mappers

Some tasks take source files and create target files. Depending on the task, it may be quite obvious which name a target file will have (using javac, you know there will be .class files for your .java files) - in other cases you may want to specify the target files, either to help Ant or to get an extra bit of functionality.

While source files are usually specified as filesets, you don't specify target files directly - instead, you tell Ant how to find the target file(s) for one source file. An instance of org.apache.tools.ant.util.FileNameMapper is responsible for this. It constructs target file names based on rules that can be parameterized with from and to attributes - the exact meaning of which is implementation-dependent.

These instances are defined in <mapper> elements with the following attributes:

Attribute Description Required
type specifies one of the built-in implementations. Exactly one of both
classname specifies the implementation by class name. Exactly one of both
classpath the classpath to use when looking up classname. No
classpathref the classpath to use, given as reference to a path defined elsewhere. No
from the from attribute for the given implementation. Depends on implementation.
to the to attribute for the given implementation. Depends on implementation.

Note that Ant will not automatically convert / or ${\backslash}$ characters in the to and from attributes to the correct directory separator of your current platform. If you need to specify this separator, use ${file.separator} instead.



Subsections
next up previous contents index
Next: Parameters specified as nested Up: Core Types Previous: FileSet   Contents   Index
Andrew Marlow 2003-07-08