- Apache ANT Tasks Tutorial
- ANT Tasks - Home
- ANT Tasks - Introduction
- ANT Tasks - Environment Setup
- Apache ANT Tasks Examples
- ANT Tasks - BaseName
- ANT Tasks - GZip
- ANT Tasks - GUnzip
- ANT Tasks - Chmod
- ANT Tasks - Concat
- ANT Tasks - Condition
- ANT Tasks - Copy
- ANT Tasks - Delete
- ANT Tasks - EAR
- ANT Tasks - Fail
- ANT Tasks - Import
- ANT Tasks - Java
- ANT Tasks - Javac
- ANT Tasks - Length
- ANT Tasks - LoadFile
- ANT Tasks - MkDir
- ANT Tasks - Move
- ANT Tasks - Sleep
- ANT Tasks - WAR
- ANT Tasks - Zip
- ANT Tasks -JAR
- Apache ANT Tasks Useful Resources
- Ant Tasks - Quick Guide
- Ant Tasks - Useful Resources
- Ant Tasks - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Apache Ant Tasks - Copy
Copy task copies a file/resource collection to a new file or directory. Files are only copied if the source file is newer than the destination file, or when the destination file does not exist.
|Sr.No||Attributes & Description|
The file to copy. (Mandatory)
Give the copied files the same last modified time as the original source files.
The file to copy to.
The directory to copy to.
Overwrite existing files even if the destination files are newer.
Overwrite read-only destination files.
Indicates whether token filtering using the global build-file filters should take place during the copy.
Ignore the directory structure of the source files, and copy all files into the directory specified by the todir attribute.
Copy any empty directories included in the FileSet(s).
If false, log a warning message, but do not stop the build, when the file to copy does not exist or one of the nested filesets points to a directory that doesn't exist or an error occurs while copying.
If true and failonerror is false, then do not log a warning message when the file to copy does not exist or one of the nested filesets points to a directory that doesn't exist or an error occurs while copying.
Log the files that are being copied.
The encoding to assume when filter-copying the files.
The encoding to use when writing the files.
If true the task will process to all the mappings for a given source path. If false the task will only process the first file or directory. This attribute is only relevant if there is a mapper subelement.
The number of milliseconds leeway to give before deciding a file is out of date. This is needed because not every file system supports tracking the last modified time to the millisecond level. This can also be useful if source and target files live on separate machines with clocks being out of sync.
Create build.xml with the following content −
<?xml version="1.0"?> <project name="TutorialPoint" default="info"> <target name="info"> <copy file="text.txt" tofile="textcopy.txt"></copy> </target> </project>
Above script will copy a file say text.txt in the current directory as textcopy.txt.
Running Ant on the above build file produces the following output −
F:\tutorialspoint\ant>ant Buildfile: F:\tutorialspoint\ant\build.xml info: [echo] Copying 1 file to F:\tutorialspoint\ant BUILD SUCCESSFUL Total time: 1 second