Class FTPTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.optional.net.FTPTask
- All Implemented Interfaces:
- Cloneable
Basic FTP client. Performs the following actions:
 
- send - send files to a remote server. This is the default action.
- get - retrieve files from a remote server.
- del - delete files from a remote server.
- list - create a file listing.
- chmod - change unix file permissions.
- rmdir - remove directories, if empty, from a remote server.
- Since:
- Ant 1.3
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classan action to perform, one of "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod", "rmdir"static classone of the valid system type keys recognized by the systemTypeKey attribute.static classrepresents one of the valid timestamp adjustment values recognized by thetimestampGranularityattribute.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final String[]static final String[]static final intstatic final String[]static final intDefault port for FTPstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddFileset(FileSet set) A set of files to upload or downloadprotected voidChecks to see that all required parameters are set.voidexecute()Runs the task.intgetChmod()booleanlongintgetPort()intlonggetUmask()booleanisBinary()booleanbooleanbooleanisNewer()booleanbooleanbooleanbooleanbooleanvoidvoidsetAccount(String pAccount) Sets the login account to use on the specified server.voidDeprecated.since 1.5.x.voidsetAction(FTPTask.Action action) Sets the FTP action to be taken.voidsetBinary(boolean binary) If true, uses binary mode, otherwise text mode (default is binary).voidSets the file permission mode (Unix only) for files sent to the server.voidsetDefaultDateFormatConfig(String defaultDateFormat) Sets the defaultDateFormatConfig attribute.voidsetDepends(boolean depends) Set to true to transmit only files that are new or changed from their remote counterparts.voidsetEnableRemoteVerification(boolean b) Whether to verify that data and control connections are connected to the same remote host.voidsetGranularityMillis(long granularity) voidsetIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) set the flag to skip errors on directory creation.voidsetInitialSiteCommand(String initialCommand) Sets the initialSiteCommand attribute.voidsetListing(File listing) The output file for the "list" action.voidsetNewer(boolean newer) A synonym fordepends.voidsetPassive(boolean passive) Specifies whether to use passive mode.voidsetPassword(String password) Sets the login password for the given user id.voidsetPort(int port) Sets the FTP port used by the remote server.voidsetPreserveLastModified(boolean preserveLastModified) Set to true to preserve modification times for "gotten" files.voidsetRecentDateFormatConfig(String recentDateFormat) Sets the recentDateFormatConfig attribute.voidsetRemotedir(String dir) Sets the remote directory where files will be placed.voidsetRetriesAllowed(String retriesAllowed) Defines how many times to retry executing FTP command before giving up.voidsetSeparator(String separator) Sets the remote file separator character.voidSets the FTP server to send files to.voidsetServerLanguageCodeConfig(String serverLanguageCode) Sets the serverLanguageCode attribute.voidsetServerTimeZoneConfig(String serverTimeZoneId) Sets the serverTimeZoneConfig attribute.voidsetShortMonthNamesConfig(String shortMonthNames) Sets the shortMonthNamesConfig attributevoidsetSiteCommand(String siteCommand) Sets the siteCommand attribute.voidsetSkipFailedTransfers(boolean skipFailedTransfers) If true, enables unsuccessful file put, delete and get operations to be skipped with a warning and the remainder of the files still transferred.voidsetSystemTypeKey(FTPTask.FTPSystemType systemKey) Sets the systemTypeKey attribute.voidsetTimeDiffAuto(boolean timeDiffAuto) "true" to find out automatically the time difference between local and remote machine.voidsetTimeDiffMillis(long timeDiffMillis) number of milliseconds to add to the time on the remote machine to get the time on the local machine.voidsetTimestampGranularity(FTPTask.Granularity timestampGranularity) Sets the timestampGranularity attributevoidSets the default mask for file creation on a unix server.protected voidvoidSets the login user id to use on the specified server.voidsetVerbose(boolean verbose) Set to true to receive notification about each file as it is transferred.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, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
- 
Field Details- 
SEND_FILESpublic static final int SEND_FILES- See Also:
 
- 
GET_FILESpublic static final int GET_FILES- See Also:
 
- 
DEL_FILESpublic static final int DEL_FILES- See Also:
 
- 
LIST_FILESpublic static final int LIST_FILES- See Also:
 
- 
MK_DIRpublic static final int MK_DIR- See Also:
 
- 
CHMODpublic static final int CHMOD- See Also:
 
- 
RM_DIRpublic static final int RM_DIR- See Also:
 
- 
SITE_CMDpublic static final int SITE_CMD- See Also:
 
- 
DEFAULT_FTP_PORTpublic static final int DEFAULT_FTP_PORTDefault port for FTP- See Also:
 
- 
ACTION_STRS
- 
COMPLETED_ACTION_STRS
- 
ACTION_TARGET_STRS
 
- 
- 
Constructor Details- 
FTPTaskpublic FTPTask()
 
- 
- 
Method Details- 
setRemotedirSets the remote directory where files will be placed. This may be a relative or absolute path, and must be in the path syntax expected by the remote server. No correction of path syntax will be performed.- Parameters:
- dir- the remote directory name.
 
- 
getRemotedir
- 
setServerSets the FTP server to send files to.- Parameters:
- server- the remote server name.
 
- 
getServer
- 
setPortpublic void setPort(int port) Sets the FTP port used by the remote server.- Parameters:
- port- the port on which the remote server is listening.
 
- 
getPortpublic int getPort()
- 
setUseridSets the login user id to use on the specified server.- Parameters:
- userid- remote system userid.
 
- 
getUserid
- 
setPasswordSets the login password for the given user id.- Parameters:
- password- the password on the remote system.
 
- 
getPassword
- 
setAccountSets the login account to use on the specified server.- Parameters:
- pAccount- the account name on remote system
- Since:
- Ant 1.7
 
- 
getAccount
- 
setBinarypublic void setBinary(boolean binary) If true, uses binary mode, otherwise text mode (default is binary).- Parameters:
- binary- if true use binary mode in transfers.
 
- 
isBinarypublic boolean isBinary()
- 
setPassivepublic void setPassive(boolean passive) Specifies whether to use passive mode. Set to true if you are behind a firewall and cannot connect without it. Passive mode is disabled by default.- Parameters:
- passive- true is passive mode should be used.
 
- 
isPassivepublic boolean isPassive()
- 
setVerbosepublic void setVerbose(boolean verbose) Set to true to receive notification about each file as it is transferred.- Parameters:
- verbose- true if verbose notifications are required.
 
- 
isVerbosepublic boolean isVerbose()
- 
setNewerpublic void setNewer(boolean newer) A synonym fordepends. Set to true to transmit only new or changed files. See the related attributes timediffmillis and timediffauto.- Parameters:
- newer- if true only transfer newer files.
 
- 
isNewerpublic boolean isNewer()
- 
setTimeDiffMillispublic void setTimeDiffMillis(long timeDiffMillis) number of milliseconds to add to the time on the remote machine to get the time on the local machine. use in conjunction withnewer- Parameters:
- timeDiffMillis- number of milliseconds
- Since:
- ant 1.6
 
- 
getTimeDiffMillispublic long getTimeDiffMillis()
- 
setTimeDiffAutopublic void setTimeDiffAuto(boolean timeDiffAuto) "true" to find out automatically the time difference between local and remote machine. This requires right to create and delete a temporary file in the remote directory.- Parameters:
- timeDiffAuto- true = find automatically the time diff
- Since:
- ant 1.6
 
- 
isTimeDiffAutopublic boolean isTimeDiffAuto()
- 
setPreserveLastModifiedpublic void setPreserveLastModified(boolean preserveLastModified) Set to true to preserve modification times for "gotten" files.- Parameters:
- preserveLastModified- if true preserver modification times.
 
- 
isPreserveLastModifiedpublic boolean isPreserveLastModified()
- 
setDependspublic void setDepends(boolean depends) Set to true to transmit only files that are new or changed from their remote counterparts. The default is to transmit all files.- Parameters:
- depends- if true only transfer newer files.
 
- 
setSeparatorSets the remote file separator character. This normally defaults to the Unix standard forward slash, but can be manually overridden using this call if the remote server requires some other separator. Only the first character of the string is used.- Parameters:
- separator- the file separator on the remote system.
 
- 
getSeparator
- 
setChmodSets the file permission mode (Unix only) for files sent to the server.- Parameters:
- theMode- unix style file mode for the files sent to the remote system.
 
- 
getChmod
- 
setUmaskSets the default mask for file creation on a unix server.- Parameters:
- theUmask- unix style umask for files created on the remote server.
 
- 
getUmask
- 
addFilesetA set of files to upload or download- Parameters:
- set- the set of files to be added to the list of files to be transferred.
 
- 
getFilesets
- 
setActionDeprecated.since 1.5.x. setAction(String) is deprecated and is replaced with setAction(FTP.Action) to make Ant's Introspection mechanism do the work and also to encapsulate operations on the type in its own class.Sets the FTP action to be taken. Currently accepts "put", "get", "del", "mkdir", "chmod", "list", and "site".- Parameters:
- action- the FTP action to be performed.
- Throws:
- BuildException- if the action is not a valid action.
 
- 
setActionSets the FTP action to be taken. Currently accepts "put", "get", "del", "mkdir", "chmod", "list", and "site".- Parameters:
- action- the FTP action to be performed.
- Throws:
- BuildException- if the action is not a valid action.
 
- 
getActionpublic int getAction()
- 
setListingThe output file for the "list" action. This attribute is ignored for any other actions.- Parameters:
- listing- file in which to store the listing.
 
- 
getListing
- 
setSkipFailedTransferspublic void setSkipFailedTransfers(boolean skipFailedTransfers) If true, enables unsuccessful file put, delete and get operations to be skipped with a warning and the remainder of the files still transferred.- Parameters:
- skipFailedTransfers- true if failures in transfers are ignored.
 
- 
isSkipFailedTransferspublic boolean isSkipFailedTransfers()
- 
setIgnoreNoncriticalErrorspublic void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) set the flag to skip errors on directory creation. (and maybe later other server specific errors)- Parameters:
- ignoreNoncriticalErrors- true if non-critical errors should not cause a failure.
 
- 
isIgnoreNoncriticalErrorspublic boolean isIgnoreNoncriticalErrors()
- 
isConfigurationSetpublic boolean isConfigurationSet()
- 
setSystemTypeKeySets the systemTypeKey attribute. Method for settingFTPClientConfigremote system key.- Parameters:
- systemKey- the key to be set - BUT if blank the default value of null (which signifies "autodetect") will be kept.
- See Also:
 
- 
setDefaultDateFormatConfigSets the defaultDateFormatConfig attribute.- Parameters:
- defaultDateFormat- configuration to be set, unless it is null or empty string, in which case ignored.
- See Also:
 
- 
setRecentDateFormatConfigSets the recentDateFormatConfig attribute.- Parameters:
- recentDateFormat- configuration to be set, unless it is null or empty string, in which case ignored.
- See Also:
 
- 
setServerLanguageCodeConfigSets the serverLanguageCode attribute.- Parameters:
- serverLanguageCode- configuration to be set, unless it is null or empty string, in which case ignored.
- See Also:
 
- 
setServerTimeZoneConfigSets the serverTimeZoneConfig attribute.- Parameters:
- serverTimeZoneId- configuration to be set, unless it is null or empty string, in which case ignored.
- See Also:
 
- 
setShortMonthNamesConfigSets the shortMonthNamesConfig attribute- Parameters:
- shortMonthNames- configuration to be set, unless it is null or empty string, in which case ignored.
- See Also:
 
- 
setRetriesAllowedDefines how many times to retry executing FTP command before giving up. Default is 0 - try once and if failure then give up.- Parameters:
- retriesAllowed- number of retries to allow. -1 means keep trying forever. "forever" may also be specified as a synonym for -1.
 
- 
getRetriesAllowedpublic int getRetriesAllowed()
- 
getSystemTypeKey- Returns:
- Returns the systemTypeKey.
 
- 
getDefaultDateFormatConfig- Returns:
- Returns the defaultDateFormatConfig.
 
- 
getRecentDateFormatConfig- Returns:
- Returns the recentDateFormatConfig.
 
- 
getServerLanguageCodeConfig- Returns:
- Returns the serverLanguageCodeConfig.
 
- 
getServerTimeZoneConfig- Returns:
- Returns the serverTimeZoneConfig.
 
- 
getShortMonthNamesConfig- Returns:
- Returns the shortMonthNamesConfig.
 
- 
getTimestampGranularity- Returns:
- Returns the timestampGranularity.
 
- 
setTimestampGranularitySets the timestampGranularity attribute- Parameters:
- timestampGranularity- The timestampGranularity to set.
 
- 
setSiteCommandSets the siteCommand attribute. This attribute names the command that will be executed if the action is "site".- Parameters:
- siteCommand- The siteCommand to set.
 
- 
getSiteCommand
- 
setInitialSiteCommandSets the initialSiteCommand attribute. This attribute names a site command that will be executed immediately after connection.- Parameters:
- initialCommand- The initialSiteCommand to set.
 
- 
getInitialSiteCommand
- 
getGranularityMillispublic long getGranularityMillis()
- 
setGranularityMillispublic void setGranularityMillis(long granularity) 
- 
setEnableRemoteVerificationpublic void setEnableRemoteVerification(boolean b) Whether to verify that data and control connections are connected to the same remote host.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
- 
getEnableRemoteVerificationpublic boolean getEnableRemoteVerification()
- 
checkAttributesChecks to see that all required parameters are set.- Throws:
- BuildException- if the configuration is not valid.
 
- 
executeRuns the task.- Overrides:
- executein class- Task
- Throws:
- BuildException- if the task fails or is not configured correctly.
 
- 
createClasspath
- 
setupFTPDelegateprotected void setupFTPDelegate()
- 
log
 
-