Apache Ant TypesApache Ant provides rich set of types, some of them are given below. We can use these to deal with data, files, path etc and can also be used as service.
ClassFileSetClassFileSet is a special type of FileSet which includes all of the class files upon which the root classes are depend. It is used to create JAR with all the required classes for a particular application. ClassFileSet are declared by the id value which is then used as reference. DirSetA DirSet is a group of directories. It supports <patternset> and it's nested elements <include>, <includesfile>, <exclude>, <excludefiles>. It has various attributes which are given below.
Apache Ant DirSet ExampleThis example will group all the directories names classess found inside the apps subdirectory of ${build.dir} and excludes which has test in their name. FileListFileList is a list (collection) of files. It can be be used with <concat>, <dependset> tasks. FileList is useful for specifying files that may or may not exists. It has attributes given below.
FileList ExampleFileSetFileSet is a group of files from a single root directory. It collects files based on patternsets specified by Ant. The <include> and <exclude> elements are called patternsets. A patternset is a collection of file matching patterns. By default these are casesensitive, but can be disabled by setting casesensitive = false. File Set has attributes which are given below.
Lets see an example and copy files from one directory to another. FileSet Example// build.xml The above code will copy all the java files from dir2 to dir1. FileMapperSometimes after executing a task, the source file and the output both are different and then not be mapped. Apache Ant uses FileMapper to map source and created target file. An instance of org.apache.tools.ant.util.FileNameMapper class and <mapper> element is used to map the files. The mapper has the following attributes.
All built-in mappers are case-sensitivity. Mapper ExampleFilterSetFilterSet is a group of filters and used by two major operations (tasks) copy and move. It uses id and refid attributes, id is used to define a FilterSet and refid is used to refer another FilterSet. It is also possible to nest FilterSet into FilterSet to get a set union of the contained filters. It has various attributes which are given below. Fileset Attributes
Here, we are copying the abc.txt file to the dist directory from the build directory but wish to replace the token @DATE@ with today's date. FilterSet ExampleNext TopicApache Ant Custom Components |