Apache Ant Chmod Task

Ant Chmod is used to change the file permissions. It works only for Unix type kernel based systems. It also allows all the arguments passed during the chmod command.

It supports all the FileSet's attributes and nested elements directly. From Ant 1.6, it also supports nested filelists.

Ant Chmod Task Attributes

AttributeDescriptionRequired
fileFile name of which the permissions must be changed.Exactly one of the two, unless nested <fileset|filelist|dirset> elements are specified
dirThe directory which holds the files whose permissions must be changed.
permthe new permissions.Yes
includesA list of patterns of files that must be included.No; defaults to all (**)
excludesA list of patterns of files that must be excluded.No; defaults to default excludes or none if defaultexcludes is no
defaultexcludesIt indicates whether default excludes should be used or not.No; defaults to yes
parallelIt process all specified files using a single chmod command.No; defaults to true
typeSet Either dir, file or both.No; default is file
maxparallelA Limit the amount of parallelism by passing at most this many sourcefiles at once.No; defaults to unlimited
verboseWhether to print a summary after execution or not.No; defaults to false
osA list of Operating Systems on which the command may be executed.No
osfamilyOS family name.No; defaults to unix

Ant Chmod Task Example

We can make start.sh file readable and executable by using the below lines.

make readable, writable and executable only for the Unix Owner.

Make all files readable, writable.





Latest Courses