Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class SetPermissions

extends Task
Class Inheritance
Imports
java.io.IOException, java.nio.file.Files, .Path, java.nio.file.attribute.DosFileAttributeView, .PosixFilePermission, java.util.Arrays, .EnumSet, .Set, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.types.Resource, .ResourceCollection, org.apache.tools.ant.types.resources.Resources, org.apache.tools.ant.util.PermissionUtils, .StringUtils

Sets PosixFilePermissions for resources.

This task provides a subset of Chmod's and org.apache.tools.ant.taskdefs.optional.windows.Attrib's abilities in less platform dependent way.

It requires a file system that supports PosixFilePermissions for its full potential. It can optionally fall back to DosFilePermissions (only changing the readonly state) on file systems that don't support POSIX permissions. See SetPermissions.NonPosixMode

Since
Ant 1.10.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
SetPermissions.NonPosixMode

Options for dealing with file systems that don't support POSIX permissions.

Field Summary

Modifier and TypeField and Description
private boolean
private SetPermissions.NonPosixMode
private final Set<PosixFilePermission>
private Resources
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(ResourceCollection
a resource collection
rc
)

Adds a collection of resources to set permissions on.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Called by the project to let the task do its work.
private boolean
private void
maybeThrowException(Exception exc, String msgFormat, Object... msgArgs)

private void
public void
setFailOnError(final boolean
true or false.
failonerror
)

Set whether to fail when errors are encountered.

public void
setMode(String
a String value
octalString
)

A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion;

public void
setNonPosixMode(SetPermissions.NonPosixMode
what to do if changing the permissions of a file is not possible
m
)

Set what to do if changing the permissions of a file is not possible because the file-system doesn't support POSIX file permissions.

public void
setPermissions(String
comma separated list of names of PosixFilePermissions.
perms
)

Adds permissions as a comma separated list.

private void
tryDos(Path p, boolean failIfDosIsNotSupported)

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

failonerrorback to summary
private boolean failonerror
nonPosixModeback to summary
private SetPermissions.NonPosixMode nonPosixMode
permissionsback to summary
private final Set<PosixFilePermission> permissions
resourcesback to summary
private Resources resources

Constructor Detail

SetPermissionsback to summary
public SetPermissions()

Method Detail

addback to summary
public void add(ResourceCollection rc)

Adds a collection of resources to set permissions on.

Parameters
rc:ResourceCollection

a resource collection

executeback to summary
public void execute()

Overrides org.apache.tools.ant.Task.execute.

Doc from org.apache.tools.ant.Task.execute.

Called by the project to let the task do its work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.

Annotations
@Override
isWritableback to summary
private boolean isWritable()
maybeThrowExceptionback to summary
private void maybeThrowException(Exception exc, String msgFormat, Object... msgArgs)
posixPermissionsNotSupportedback to summary
private void posixPermissionsNotSupported(Path p)
setFailOnErrorback to summary
public void setFailOnError(final boolean failonerror)

Set whether to fail when errors are encountered. If false, note errors to the output but keep going. Default is true.

Only applies to IO and SecurityExceptions, see setNonPosixMode for ways to deal with file-systems that don't support PosixPermissions.

Parameters
failonerror:boolean

true or false.

setModeback to summary
public void setMode(String octalString)

A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion;

Parameters
octalString:String

a String value

setNonPosixModeback to summary
public void setNonPosixMode(SetPermissions.NonPosixMode m)

Set what to do if changing the permissions of a file is not possible because the file-system doesn't support POSIX file permissions.

The default is NonPosixMode#fail.

Parameters
m:SetPermissions.NonPosixMode

what to do if changing the permissions of a file is not possible

setPermissionsback to summary
public void setPermissions(String perms)

Adds permissions as a comma separated list.

Parameters
perms:String

comma separated list of names of PosixFilePermissions.

tryDosback to summary
private void tryDos(Path p, boolean failIfDosIsNotSupported)
org.apache.tools.ant.taskdefs back to summary

public final Enum SetPermissions.NonPosixMode

extends Enum<SetPermissions.NonPosixMode>
Class Inheritance

Options for dealing with file systems that don't support POSIX permissions.

Field Summary

Modifier and TypeField and Description
public static final SetPermissions.NonPosixMode
fail

Fail the build.

public static final SetPermissions.NonPosixMode
pass

Log an error and go on.

public static final SetPermissions.NonPosixMode
tryDosOrFail

Try DosFilePermissions - setting the read-only flag - and fail the build if that fails as well.

public static final SetPermissions.NonPosixMode
tryDosOrPass

Try DosFilePermissions - setting the read-only flag - and log an error and go on if that fails as well.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static SetPermissions.NonPosixMode
public static SetPermissions.NonPosixMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

failback to summary
public static final SetPermissions.NonPosixMode fail

Fail the build.

passback to summary
public static final SetPermissions.NonPosixMode pass

Log an error and go on.

tryDosOrFailback to summary
public static final SetPermissions.NonPosixMode tryDosOrFail

Try DosFilePermissions - setting the read-only flag - and fail the build if that fails as well.

tryDosOrPassback to summary
public static final SetPermissions.NonPosixMode tryDosOrPass

Try DosFilePermissions - setting the read-only flag - and log an error and go on if that fails as well.

Constructor Detail

NonPosixModeback to summary
private NonPosixMode()

Method Detail

valueOfback to summary
public static SetPermissions.NonPosixMode valueOf(String name)
valuesback to summary
public static SetPermissions.NonPosixMode[] values()