Class Chmod
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.ExecTask
org.apache.tools.ant.taskdefs.ExecuteOn
org.apache.tools.ant.taskdefs.Chmod
- All Implemented Interfaces:
Cloneable
Chmod equivalent for unix-like environments.
- Since:
- Ant 1.1
- To do:
- Refactor so it does not extend from ExecuteOn and then turn around and unsupport several attributes.
-
Nested Class Summary
Nested classes/interfaces inherited from class ExecuteOn
ExecuteOn.FileDirBothModifier and TypeClassDescriptionstatic classEnumerated attribute with the values "file", "dir" and "both" for the type attribute. -
Field Summary
Fields inherited from class ExecuteOn
destDir, filesets, mapper, mapperElement, srcFilePos, srcIsFirst, targetFilePos, typeModifier and TypeFieldDescriptionprotected Fileprotected Vector<AbstractFileSet> protected FileNameMapperprotected Mapperprotected Commandline.Markerprotected booleanHas <srcfile> been specified before <targetfile>protected Commandline.Markerprotected StringFields inherited from class ExecTask
cmdl, failOnError, newEnvironment, redirector, redirectorElementModifier and TypeFieldDescriptionprotected Commandlineprotected booleanprotected booleanprotected Redirectorprotected RedirectorElementFields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck the attributes and nested elements.Add a name entry on the exclude list.Add a name entry on the include list.Add a set of patterns.voidexecute()Carry out the chmoding.protected booleanCheck if the os is valid.voidsetAddsourcefile(boolean b) This is not allowed for Chmod.voidsetCommand(Commandline cmdl) Set the command.voidsetDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.voidThe directory which holds the files whose permissions must be changed.voidsetExcludes(String excludes) Sets the set of exclude patterns.voidSet the executable.voidThe file or single directory of which the permissions must be changed.voidsetIncludes(String includes) Sets the set of include patterns.voidSet the new permissions.voidsetProject(Project project) Set the project of this task.voidsetSkipEmptyFilesets(boolean skip) This is not allowed for Chmod.Methods inherited from class ExecuteOn
add, add, addDirset, addFilelist, addFileset, createHandler, createMapper, createSrcfile, createTargetfile, getCommandline, getCommandline, getDirs, getFiles, getFilesAndDirs, runExec, runParallel, setDest, setForce, setForwardslash, setIgnoremissing, setMaxParallel, setParallel, setRelative, setType, setupRedirector, setVerboseModifier and TypeMethodDescriptionvoidAdd a collection of resources upon which to operate.voidadd(FileNameMapper fileNameMapper) Add a nested FileNameMapper.voidAdd a set of directories upon which to operate.voidaddFilelist(FileList list) Add a list of source files upon which to operate.voidaddFileset(FileSet set) Add a set of files upon which to operate.protected ExecuteStreamHandlerCreate the ExecuteStreamHandler instance that will be used during execution.Create a nested Mapper element to use for mapping source files to target files.Create a placeholder indicating where on the command line the name of the source file should be inserted.Create a placeholder indicating where on the command line the name of the target file should be inserted.protected String[]getCommandline(String[] srcFiles, File[] baseDirs) Construct the command line for parallel execution.protected String[]getCommandline(String srcFile, File baseDir) Construct the command line for serial execution.protected String[]getDirs(File baseDir, DirectoryScanner ds) Return the list of Directories from this DirectoryScanner that should be included on the command line.protected String[]getFiles(File baseDir, DirectoryScanner ds) Return the list of files from this DirectoryScanner that should be included on the command line.protected String[]getFilesAndDirs(FileList list) Return the list of files or directories from this FileList that should be included on the command line.protected voidRun the specified Execute object.protected voidRun the command in "parallel" mode, making sure that at most maxParallel sourcefiles get passed on the command line.voidSpecify the directory where target files are to be placed.voidsetForce(boolean b) Set whether to bypass timestamp comparisons for target files.voidsetForwardslash(boolean forwardSlash) Set whether the source and target file names on Windows and OS/2 must use the forward slash as file separator.voidsetIgnoremissing(boolean b) Set whether to ignore nonexistent files from filelists.voidsetMaxParallel(int max) Limit the command line length by passing at maximum this many sourcefiles at once to the command.voidsetParallel(boolean parallel) Set whether to execute in parallel mode.voidsetRelative(boolean relative) Set whether the filenames should be passed on the command line as absolute or relative pathnames.voidsetType(ExecuteOn.FileDirBoth type) Set whether the command works only on files, directories or both.protected voidSet up the I/O Redirector.voidsetVerbose(boolean b) Set whether to operate in verbose mode.Methods inherited from class ExecTask
addConfiguredRedirector, addEnv, createArg, createWatchdog, getOs, getOsFamily, getResolveExecutable, logFlush, maybeSetResultPropertyValue, prepareExec, resolveExecutable, runExecute, setAppend, setDiscardError, setDiscardOutput, setError, setErrorProperty, setFailIfExecutionFails, setFailonerror, setInput, setInputString, setLogError, setNewenvironment, setOs, setOsFamily, setOutput, setOutputproperty, setResolveExecutable, setResultProperty, setSearchPath, setSpawn, setTimeout, setTimeout, setVMLauncherModifier and TypeMethodDescriptionvoidaddConfiguredRedirector(RedirectorElement redirectorElement) Add aRedirectorElementto this task.voidAdd an environment variable to the launched process.Adds a command-line argument.protected ExecuteWatchdogCreate the Watchdog to kill a runaway process.final StringgetOs()List of operating systems on which the command may be executed.final StringRestrict this execution to a single OS FamilybooleanIndicates whether to attempt to resolve the executable to a file.protected voidlogFlush()Flush the output stream - if there is one.protected voidmaybeSetResultPropertyValue(int result) Helper method to set result property to the passed in value if appropriate.protected ExecuteCreate an Execute instance with the correct working directory set.protected StringresolveExecutable(String exec, boolean mustSearchPath) The method attempts to figure out where the executable is so that we can feed the full path.protected final voidrunExecute(Execute exe) A Utility method for this classes and subclasses to run an Execute instance (an external command).voidsetAppend(boolean append) Set whether output should be appended to or overwrite an existing file.voidsetDiscardError(boolean discard) Whether error output should be discarded.voidsetDiscardOutput(boolean discard) Whether output should be discarded.voidSet the File to which the error stream of the process should be redirected.voidsetErrorProperty(String errorProperty) Sets the name of the property whose value should be set to the error of the process.voidsetFailIfExecutionFails(boolean flag) Set whether to stop the build if program cannot be started.voidsetFailonerror(boolean fail) Fail if the command exits with a non-zero return code.voidSet the input file to use for the task.voidsetInputString(String inputString) Set the string to use as input.voidsetLogError(boolean logError) Controls whether error output of exec is logged.voidsetNewenvironment(boolean newenv) Do not propagate old environment when new environment variables are specified.voidList of operating systems on which the command may be executed.voidsetOsFamily(String osFamily) Restrict this execution to a single OS FamilyvoidFile the output of the process is redirected to.voidsetOutputproperty(String outputProp) Sets the property name whose value should be set to the output of the process.voidsetResolveExecutable(boolean resolveExecutable) Set whether to attempt to resolve the executable to a file.voidsetResultProperty(String resultProperty) Sets the name of a property in which the return code of the command should be stored.voidsetSearchPath(boolean searchPath) Set whether to search nested, then system PATH environment variables for the executable.voidsetSpawn(boolean spawn) Set whether or not you want the process to be spawned.voidsetTimeout(Integer value) Set the timeout in milliseconds after which the process will be killed.voidsetTimeout(Long value) Set the timeout in milliseconds after which the process will be killed.voidsetVMLauncher(boolean vmLauncher) Set whether to launch new process with VM, otherwise use the OS's shell.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.voidinit()Called by the project to let the task initialize properly.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocationModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.
-
Constructor Details
-
Chmod
public Chmod()Chmod task for setting file and directory permissions.
-
-
Method Details
-
setProject
Set the project of this task. Calls the super class and sets the project on dhe default FileSet.- Overrides:
setProjectin classProjectComponent- Parameters:
project- the project for this task.- See Also:
-
setFile
The file or single directory of which the permissions must be changed.- Parameters:
src- the source file or directory.
-
setDir
-
setPerm
-
createInclude
Add a name entry on the include list.- Returns:
- a NameEntry to be configured.
-
createExclude
Add a name entry on the exclude list.- Returns:
- a nameentry to be configured.
-
createPatternSet
-
setIncludes
Sets the set of include patterns. Patterns may be separated by a comma or a space.- Parameters:
includes- the string containing the include patterns.
-
setExcludes
Sets the set of exclude patterns. Patterns may be separated by a comma or a space.- Parameters:
excludes- the string containing the exclude patterns.
-
setDefaultexcludes
public void setDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.- Parameters:
useDefaultExcludes- "true"|"on"|"yes" when default exclusions should be used, "false"|"off"|"no" when they shouldn't be used.
-
checkConfiguration
protected void checkConfiguration()Check the attributes and nested elements.- Overrides:
checkConfigurationin classExecuteOn
-
execute
Carry out the chmoding.- Overrides:
executein classExecTask- Throws:
BuildException- on error.
-
setExecutable
Set the executable. This is not allowed for Chmod.- Overrides:
setExecutablein classExecTask- Parameters:
e- ignored.- Throws:
BuildException- always.
-
setCommand
Set the command. This is not allowed for Chmod.- Overrides:
setCommandin classExecTask- Parameters:
cmdl- ignored.- Throws:
BuildException- always.
-
setSkipEmptyFilesets
public void setSkipEmptyFilesets(boolean skip) This is not allowed for Chmod.- Overrides:
setSkipEmptyFilesetsin classExecuteOn- Parameters:
skip- ignored.- Throws:
BuildException- always.
-
setAddsourcefile
public void setAddsourcefile(boolean b) This is not allowed for Chmod.- Overrides:
setAddsourcefilein classExecuteOn- Parameters:
b- ignored.- Throws:
BuildException- always.
-
isValidOs
-