## SetPermissions

Since Ant 1.10.0.

### Description

Changes the file permissions using Java's NIO support for permissions.

This task provides a subset of the platform specific abilities of chmod and attrib in a platform independent way.

If no permissions are specified either via the mode or the permissions attribute, then all permissions will be removed from the nested resources.

The task accepts arbitrary resources as part of the nested resource collections, but not all resources support setting permissions. This task won't do anything for resources that don't support setting permissions—for example URLs.

The permissions are applied to all resources contained within the nested resources collections. You may want to ensure the collection only returns files or directories if you want different sets of permissions to apply to either type of resource.

### Parameters

Attribute | Description | Required
--- | --- | ---
permissions | The permissions to set as comma separated list of names of PosixFilePermission values. | No
mode | The permissions to set as traditional Unix three-digit octal number. | No
nonPosixMode | What to do if changing the permissions of a file is not possible because the file-system doesn't support POSIX file permissions. Possible options are fail (fail the build), pass (just log an error), tryDosOrFail (at least try to set the read-only flag on DOS file systems, fail if that isn't possible either) and tryDosOrPass (at least try to set the read-only flag on DOS file systems, just log an error if that isn't possible either). | No; defaults to fail
failonerror | Whether to stop the build if setting permissions fails. | No; defaults to true

### Parameters specified as nested elements

#### any resource collection

resource collections are used to select groups of resources.

### Examples

Make the `start.sh` file readable and executable for anyone and in addition writable by the owner.

    <setpermissions mode="755">
      <file file="${dist}/start.sh"/>
    </setpermissions>

Make the `start.sh` file readable and executable for anyone and in addition writable by the owner.

    <setpermissions permissions="OWNER_READ,OWNER_WRITE,OWNER_EXECUTE,OTHERS_READ,OTHERS_EXECUTE,GROUP_READ,GROUP_EXECUTE">
      <file file="${dist}/start.sh"/>
    </setpermissions>