Package org.apache.tools.ant.taskdefs
Class ExecuteOn
- 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
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable
 - Direct Known Subclasses:
- AbstractAccessTask,- Attrib,- Chmod,- Transform
 
 public class ExecuteOn extends ExecTask Executes a given command, supplying a set of files as arguments.- Since:
- Ant 1.2
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classExecuteOn.FileDirBothEnumerated attribute with the values "file", "dir" and "both" for the type attribute.
 - 
Field SummaryFields Modifier and Type Field Description protected java.io.FiledestDirprotected java.util.Vector<AbstractFileSet>filesetsprotected FileNameMappermapperprotected MappermapperElementprotected Commandline.MarkersrcFilePosprotected booleansrcIsFirstHas <srcfile> been specified before <targetfile>protected Commandline.MarkertargetFilePosprotected java.lang.Stringtype- 
Fields inherited from class org.apache.tools.ant.taskdefs.ExecTaskcmdl, failOnError, newEnvironment, redirector, redirectorElement
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description ExecuteOn()
 - 
Method SummaryModifier and Type Method Description voidadd(ResourceCollection rc)Add a collection of resources upon which to operate.voidadd(FileNameMapper fileNameMapper)Add a nested FileNameMapper.voidaddDirset(DirSet set)Add 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 voidcheckConfiguration()Check the configuration of this ExecuteOn instance.protected ExecuteStreamHandlercreateHandler()Create the ExecuteStreamHandler instance that will be used during execution.MappercreateMapper()Create a nested Mapper element to use for mapping source files to target files.Commandline.MarkercreateSrcfile()Create a placeholder indicating where on the command line the name of the source file should be inserted.Commandline.MarkercreateTargetfile()Create a placeholder indicating where on the command line the name of the target file should be inserted.protected java.lang.String[]getCommandline(java.lang.String[] srcFiles, java.io.File[] baseDirs)Construct the command line for parallel execution.protected java.lang.String[]getCommandline(java.lang.String srcFile, java.io.File baseDir)Construct the command line for serial execution.protected java.lang.String[]getDirs(java.io.File baseDir, DirectoryScanner ds)Return the list of Directories from this DirectoryScanner that should be included on the command line.protected java.lang.String[]getFiles(java.io.File baseDir, DirectoryScanner ds)Return the list of files from this DirectoryScanner that should be included on the command line.protected java.lang.String[]getFilesAndDirs(FileList list)Return the list of files or directories from this FileList that should be included on the command line.protected voidrunExec(Execute exe)Run the specified Execute object.protected voidrunParallel(Execute exe, java.util.Vector<java.lang.String> fileNames, java.util.Vector<java.io.File> baseDirs)Run the command in "parallel" mode, making sure that at most maxParallel sourcefiles get passed on the command line.voidsetAddsourcefile(boolean b)Set whether to send the source file name on the command line.voidsetDest(java.io.File destDir)Specify 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.voidsetSkipEmptyFilesets(boolean skip)Set whether empty filesets will be skipped.voidsetType(ExecuteOn.FileDirBoth type)Set whether the command works only on files, directories or both.protected voidsetupRedirector()Set up the I/O Redirector.voidsetVerbose(boolean b)Set whether to operate in verbose mode.- 
Methods inherited from class org.apache.tools.ant.taskdefs.ExecTaskaddConfiguredRedirector, addEnv, createArg, createWatchdog, execute, getOs, getOsFamily, getResolveExecutable, isValidOs, logFlush, maybeSetResultPropertyValue, prepareExec, resolveExecutable, runExecute, setAppend, setCommand, setDir, setError, setErrorProperty, setExecutable, setFailIfExecutionFails, setFailonerror, setInput, setInputString, setLogError, setNewenvironment, setOs, setOsFamily, setOutput, setOutputproperty, setResolveExecutable, setResultProperty, setSearchPath, setSpawn, setTimeout, setTimeout, setVMLauncher
 - 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Field Detail- 
filesetsprotected java.util.Vector<AbstractFileSet> filesets 
 - 
typeprotected java.lang.String type 
 - 
srcFilePosprotected Commandline.Marker srcFilePos 
 - 
targetFilePosprotected Commandline.Marker targetFilePos 
 - 
mapperElementprotected Mapper mapperElement 
 - 
mapperprotected FileNameMapper mapper 
 - 
destDirprotected java.io.File destDir 
 - 
srcIsFirstprotected boolean srcIsFirst Has <srcfile> been specified before <targetfile>
 
- 
 - 
Method Detail- 
addFilesetpublic void addFileset(FileSet set) Add a set of files upon which to operate.- Parameters:
- set- the FileSet to add.
 
 - 
addDirsetpublic void addDirset(DirSet set) Add a set of directories upon which to operate.- Parameters:
- set- the DirSet to add.
- Since:
- Ant 1.6
 
 - 
addFilelistpublic void addFilelist(FileList list) Add a list of source files upon which to operate.- Parameters:
- list- the FileList to add.
 
 - 
addpublic void add(ResourceCollection rc) Add a collection of resources upon which to operate.- Parameters:
- rc- resource collection to add.
- Since:
- Ant 1.7
 
 - 
setRelativepublic void setRelative(boolean relative) Set whether the filenames should be passed on the command line as absolute or relative pathnames. Paths are relative to the base directory of the corresponding fileset for source files or the dest attribute for target files.- Parameters:
- relative- whether to pass relative pathnames.
 
 - 
setParallelpublic void setParallel(boolean parallel) Set whether to execute in parallel mode. If true, run the command only once, appending all files as arguments. If false, command will be executed once for every file. Defaults to false.- Parameters:
- parallel- whether to run in parallel.
 
 - 
setTypepublic void setType(ExecuteOn.FileDirBoth type) Set whether the command works only on files, directories or both.- Parameters:
- type- a FileDirBoth EnumeratedAttribute.
 
 - 
setSkipEmptyFilesetspublic void setSkipEmptyFilesets(boolean skip) Set whether empty filesets will be skipped. If true and no source files have been found or are newer than their corresponding target files, the command will not be run.- Parameters:
- skip- whether to skip empty filesets.
 
 - 
setDestpublic void setDest(java.io.File destDir) Specify the directory where target files are to be placed.- Parameters:
- destDir- the File object representing the destination directory.
 
 - 
setForwardslashpublic void setForwardslash(boolean forwardSlash) Set whether the source and target file names on Windows and OS/2 must use the forward slash as file separator.- Parameters:
- forwardSlash- whether the forward slash will be forced.
 
 - 
setMaxParallelpublic void setMaxParallel(int max) Limit the command line length by passing at maximum this many sourcefiles at once to the command.Set to <= 0 for unlimited - this is the default. - Parameters:
- max-- intmaximum number of sourcefiles passed to the executable.
- Since:
- Ant 1.6
 
 - 
setAddsourcefilepublic void setAddsourcefile(boolean b) Set whether to send the source file name on the command line.Defaults to true.- Parameters:
- b- whether to add the source file to the command line.
- Since:
- Ant 1.6
 
 - 
setVerbosepublic void setVerbose(boolean b) Set whether to operate in verbose mode. If true, a verbose summary will be printed after execution.- Parameters:
- b- whether to operate in verbose mode.
- Since:
- Ant 1.6
 
 - 
setIgnoremissingpublic void setIgnoremissing(boolean b) Set whether to ignore nonexistent files from filelists.- Parameters:
- b- whether to ignore missing files.
- Since:
- Ant 1.6.2
 
 - 
setForcepublic void setForce(boolean b) Set whether to bypass timestamp comparisons for target files.- Parameters:
- b- whether to bypass timestamp comparisons.
- Since:
- Ant 1.6.3
 
 - 
createSrcfilepublic Commandline.Marker createSrcfile() Create a placeholder indicating where on the command line the name of the source file should be inserted.- Returns:
- Commandline.Marker.
 
 - 
createTargetfilepublic Commandline.Marker createTargetfile() Create a placeholder indicating where on the command line the name of the target file should be inserted.- Returns:
- Commandline.Marker.
 
 - 
createMapperpublic Mapper createMapper() throws BuildException Create a nested Mapper element to use for mapping source files to target files.- Returns:
- Mapper.
- Throws:
- BuildException- if more than one mapper is defined.
 
 - 
addpublic void add(FileNameMapper fileNameMapper) Add a nested FileNameMapper.- Parameters:
- fileNameMapper- the mapper to add.
- Since:
- Ant 1.6.3
 
 - 
checkConfigurationprotected void checkConfiguration() Check the configuration of this ExecuteOn instance.- Overrides:
- checkConfigurationin class- ExecTask
 
 - 
createHandlerprotected ExecuteStreamHandler createHandler() throws BuildException Create the ExecuteStreamHandler instance that will be used during execution.- Overrides:
- createHandlerin class- ExecTask
- Returns:
- ExecuteStreamHandler.
- Throws:
- BuildException- on error.
 
 - 
setupRedirectorprotected void setupRedirector() Set up the I/O Redirector.- Overrides:
- setupRedirectorin class- ExecTask
 
 - 
runExecprotected void runExec(Execute exe) throws BuildException Run the specified Execute object.- Overrides:
- runExecin class- ExecTask
- Parameters:
- exe- the Execute instance representing the external process.
- Throws:
- BuildException- on error
 
 - 
getCommandlineprotected java.lang.String[] getCommandline(java.lang.String[] srcFiles, java.io.File[] baseDirs)Construct the command line for parallel execution.- Parameters:
- srcFiles- The filenames to add to the commandline.
- baseDirs- filenames are relative to this dir.
- Returns:
- the command line in the form of a String[].
 
 - 
getCommandlineprotected java.lang.String[] getCommandline(java.lang.String srcFile, java.io.File baseDir)Construct the command line for serial execution.- Parameters:
- srcFile- The filename to add to the commandline.
- baseDir- filename is relative to this dir.
- Returns:
- the command line in the form of a String[].
 
 - 
getFilesprotected java.lang.String[] getFiles(java.io.File baseDir, DirectoryScanner ds)Return the list of files from this DirectoryScanner that should be included on the command line.- Parameters:
- baseDir- the File base directory.
- ds- the DirectoryScanner to use for file scanning.
- Returns:
- a String[] containing the filenames.
 
 - 
getDirsprotected java.lang.String[] getDirs(java.io.File baseDir, DirectoryScanner ds)Return the list of Directories from this DirectoryScanner that should be included on the command line.- Parameters:
- baseDir- the File base directory.
- ds- the DirectoryScanner to use for file scanning.
- Returns:
- a String[] containing the directory names.
 
 - 
getFilesAndDirsprotected java.lang.String[] getFilesAndDirs(FileList list) Return the list of files or directories from this FileList that should be included on the command line.- Parameters:
- list- the FileList to check.
- Returns:
- a String[] containing the directory names.
- Since:
- Ant 1.6.2
 
 - 
runParallelprotected void runParallel(Execute exe, java.util.Vector<java.lang.String> fileNames, java.util.Vector<java.io.File> baseDirs) throws java.io.IOException, BuildException Run the command in "parallel" mode, making sure that at most maxParallel sourcefiles get passed on the command line.- Parameters:
- exe- the Executable to use.
- fileNames- the Vector of filenames.
- baseDirs- the Vector of base directories corresponding to fileNames.
- Throws:
- java.io.IOException- on I/O errors.
- BuildException- on other errors.
- Since:
- Ant 1.6
 
 
- 
 
-