Directory and File System Tasks


Directory and File System Tasks

These are tasks focusing on file-based issues.

Chmod Task

The chmod task changes file permissions on Unix systems:

 <chmod file="[file]" perm="[permissions]"/> 

Parameters

  • file*: File or directory on which to alter permissions.

  • dir: Directory whose files and directories are targeted to have their permissions changed:

     <chmod dir="[path]" perm="[permissions]"/> 
  • perm*: Value to which the targeted files or directories permissions will be set. On Unix systems, there are typically three groups: User, Group , and Other. The three values used most often to set these values are Read, Write, and Execute.

  • defaultexcludes: A value of yes or no. Indicates whether default excludes are used.

  • includes: A comma-separated list of patterns to include in the file set. All other files are excluded.

  • includesfile: A file source of patterns to include in the file set. All other files will be excluded.

  • excludes: A comma-separated list of patterns to exclude in the file set. All other files are included.

  • excludesfile: A file source of patterns to exclude in the file set. All other files will be included.

  • parallel: If false, more then one chmod command can be used. Defaults to true.

  • type: A value of file, dir, or both; defaults to file. The file command sends only file names as system commands. The dir command sends the directory name to be used to determine what files to execute. The both command uses the file names and directory names .

Nested Parameters

  • fileset: Specifies a collections of files (see section Frequently Used Nested Parameters and Elements at the end of this chapter for more information).

Copy Task

The copy task attempts to create a copy of a file/directory structure and place it in a specified directory:

 <copy file="[file name]" todir="[directory]"/> 

Source files that are older then the destination files are not copied unless otherwise specified with the overwrite parameter. You can also use this command to copy a source file to a destination of a different name.

Parameters

  • file*: File name of the source target file. When youre using a nested file set, the todir or tofile parameter is required, instead.

  • preservelastmodified: Boolean value of yes or no. It gives the destination files the same creation dates as the source files.

  • tofile: Name of the destination file name target:

     <copy file="[file name]" tofile="[file name]"/> 
  • todir*: Name of the destination directory target.

  • overwrite: When set to yes, older source files will overwrite newer files in the destination. Defaults to no.

  • filtering: When set to yes, turns on token filtering (for more information, see the section Ant Parent Elements" earlier in this chapter.) Defaults to no.

  • flatten: When set to yes, the target is identical to the source name and the directory structure is stripped off, effectively making the branch of the directory tree flat. Defaults to no.

  • includeEmptyDirs: When set to no, the empty directories in a file set are not created in the destination target. Defaults to yes.

Nested Parameters

  • fileset: Specifies a collections of files (see section Frequently Used Nested Parameters and Elements at the end of this chapter for more information).

  • mapper: A definition can be found under the Frequently Used Nested Parameters section at the end of this chapter.

Delete Task

The delete task removes a file or a file structure from a directory structure:

 <delete file="/lib/foo.jar"/> 

If the file or directory does not exist, execution is halted, unless the quiet parameter is set to true.

Parameters

  • file*: File name of the target to be removed.

  • dir: Directory name of the target to be removed:

     <delete dir="../foo"/> 
  • verbose: When set to false, deleted files will not be written out during execution. Defaults to true.

  • quiet: When set to true, the build wont fail if the item does not exist when delete is called. Error messages pertaining to files or directories that dont exist will also be suppressed. Defaults to false.

  • includeEmptyDirs: When set to true while using a fileset, empty directories will be deleted. Defaults to false.

Nested Parameters

  • fileset: Specifies a collections of files (see section Frequently Used Nested Parameters and Elements at the end of this chapter for more information).

  • mapper: A definition can be found under the Frequently Used Nested Parameters section at the end of this chapter.

Mkdir Task

The mkdir task creates a directory structure, adding directories when needed:

 <mkdir dir="[directory]> 

Parameter

  • dir*: The directory structure to create.

Move Task

The move task attempts to delete the source file or single directory while creating a copy of that file or directory in a new location:

 <move file="[file]" todir="[directory]"/> 

Using move in conjunction with a fileset parameter enables you to move groups of files and directory structures. This command can also be used to move a source file to a destination with a different name.

Parameters

  • file*: The file name of the source target file to be removed.

  • tofile: The name that the file will have when written:

     <move file="[file]" tofile="[file]"/> 
  • todir*: The name of the destination directory.

  • overwrite: When set to yes, older source files will overwrite newer files in the destination. Defaults to no.

  • filtering: When set to on, token filtering is used. Defaults to off.

  • flatten: When set to yes, the target is identical to the source name and the directory structure is stripped off, effectively making the branch of the directory tree flat. Defaults to no.

  • includeEmptyDirs: When set to no, the empty directories in a file set will not be created in the destination target. Defaults to yes.

Nested Parameters

  • fileset: Specifies a collections of files (see section Frequently Used Nested Parameters and Elements at the end of this chapter for more information).

  • mapper: A definition can be found under the Frequently Used Nested Parameters section at the end of this chapter.

Touch Task

The touch task changes the modification time of existing files to the current time, unless a time is specifically stated. If the file does not exist, it is created:

 <touch file="[file]"/> 

Parameters

  • file*: Name of the file to manipulate or create.

  • millis: The modification time in seconds since Jan 1 1970.

  • datetime: The modification time in the format MM/DD/YYYY HH:MM AM:

     <touch file="[file]" datetime="01/01/2000 12:00 am"/> 



Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net