All Implemented Interfaces:

public class FTPTask extends Task
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.
Note: Some FTP servers - notably the Solaris server - seem to hold data ports open after a "retr" operation, allowing them to timeout instead of shutting them down cleanly. This happens in active or passive mode, and the ports will remain open even after ending the FTP session. FTP "send" operations seem to close ports immediately. This behavior may cause problems on some systems when downloading large sets of files.
Ant 1.3
  • Field Details

  • Constructor Details

    • FTPTask

      public FTPTask()
  • Method Details

    • setRemotedir

      public void setRemotedir(String dir)
      Sets 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.
      dir - the remote directory name.
    • getRemotedir

      public String getRemotedir()
    • setServer

      public void setServer(String server)
      Sets the FTP server to send files to.
      server - the remote server name.
    • getServer

      public String getServer()
    • setPort

      public void setPort(int port)
      Sets the FTP port used by the remote server.
      port - the port on which the remote server is listening.
    • getPort

      public int getPort()
    • setUserid

      public void setUserid(String userid)
      Sets the login user id to use on the specified server.
      userid - remote system userid.
    • getUserid

      public String getUserid()
    • setPassword

      public void setPassword(String password)
      Sets the login password for the given user id.
      password - the password on the remote system.
    • getPassword

      public String getPassword()
    • setAccount

      public void setAccount(String pAccount)
      Sets the login account to use on the specified server.
      pAccount - the account name on remote system
      Ant 1.7
    • getAccount

      public String getAccount()
    • setBinary

      public void setBinary(boolean binary)
      If true, uses binary mode, otherwise text mode (default is binary).
      binary - if true use binary mode in transfers.
    • isBinary

      public boolean isBinary()
    • setPassive

      public 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.
      passive - true is passive mode should be used.
    • isPassive

      public boolean isPassive()
    • setVerbose

      public void setVerbose(boolean verbose)
      Set to true to receive notification about each file as it is transferred.
      verbose - true if verbose notifications are required.
    • isVerbose

      public boolean isVerbose()
    • setNewer

      public void setNewer(boolean newer)
      A synonym for depends. Set to true to transmit only new or changed files. See the related attributes timediffmillis and timediffauto.
      newer - if true only transfer newer files.
    • isNewer

      public boolean isNewer()
    • setTimeDiffMillis

      public 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 with newer
      timeDiffMillis - number of milliseconds
      ant 1.6
    • getTimeDiffMillis

      public long getTimeDiffMillis()
    • setTimeDiffAuto

      public 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.
      timeDiffAuto - true = find automatically the time diff
      ant 1.6
    • isTimeDiffAuto

      public boolean isTimeDiffAuto()
    • setPreserveLastModified

      public void setPreserveLastModified(boolean preserveLastModified)
      Set to true to preserve modification times for "gotten" files.
      preserveLastModified - if true preserver modification times.
    • isPreserveLastModified

      public boolean isPreserveLastModified()
    • setDepends

      public 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.
      depends - if true only transfer newer files.
    • setSeparator

      public void setSeparator(String separator)
      Sets 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.
      separator - the file separator on the remote system.
    • getSeparator

      public String getSeparator()
    • setChmod

      public void setChmod(String theMode)
      Sets the file permission mode (Unix only) for files sent to the server.
      theMode - unix style file mode for the files sent to the remote system.
    • getChmod

      public String getChmod()
    • setUmask

      public void setUmask(String theUmask)
      Sets the default mask for file creation on a unix server.
      theUmask - unix style umask for files created on the remote server.
    • getUmask

      public String getUmask()
    • addFileset

      public void addFileset(FileSet set)
      A set of files to upload or download
      set - the set of files to be added to the list of files to be transferred.
    • getFilesets

      public Vector<FileSet> getFilesets()
    • setAction

      @Deprecated public void setAction(String action) throws BuildException
      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".
      action - the FTP action to be performed.
      BuildException - if the action is not a valid action.
    • setAction

      public void setAction(FTPTask.Action action) throws BuildException
      Sets the FTP action to be taken. Currently accepts "put", "get", "del", "mkdir", "chmod", "list", and "site".
      action - the FTP action to be performed.
      BuildException - if the action is not a valid action.
    • getAction

      public int getAction()
    • setListing

      public void setListing(File listing)
      The output file for the "list" action. This attribute is ignored for any other actions.
      listing - file in which to store the listing.
    • getListing

      public File getListing()
    • setSkipFailedTransfers

      public 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.
      skipFailedTransfers - true if failures in transfers are ignored.
    • isSkipFailedTransfers

      public boolean isSkipFailedTransfers()
    • setIgnoreNoncriticalErrors

      public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors)
      set the flag to skip errors on directory creation. (and maybe later other server specific errors)
      ignoreNoncriticalErrors - true if non-critical errors should not cause a failure.
    • isIgnoreNoncriticalErrors

      public boolean isIgnoreNoncriticalErrors()
    • isConfigurationSet

      public boolean isConfigurationSet()
    • setSystemTypeKey

      public void setSystemTypeKey(FTPTask.FTPSystemType systemKey)
      Sets the systemTypeKey attribute. Method for setting FTPClientConfig remote system key.
      systemKey - the key to be set - BUT if blank the default value of null (which signifies "autodetect") will be kept.
      See Also:
      • FTPClientConfig
    • setDefaultDateFormatConfig

      public void setDefaultDateFormatConfig(String defaultDateFormat)
      Sets the defaultDateFormatConfig attribute.
      defaultDateFormat - configuration to be set, unless it is null or empty string, in which case ignored.
      See Also:
      • FTPClientConfig
    • setRecentDateFormatConfig

      public void setRecentDateFormatConfig(String recentDateFormat)
      Sets the recentDateFormatConfig attribute.
      recentDateFormat - configuration to be set, unless it is null or empty string, in which case ignored.
      See Also:
      • FTPClientConfig
    • setServerLanguageCodeConfig

      public void setServerLanguageCodeConfig(String serverLanguageCode)
      Sets the serverLanguageCode attribute.
      serverLanguageCode - configuration to be set, unless it is null or empty string, in which case ignored.
      See Also:
      • FTPClientConfig
    • setServerTimeZoneConfig

      public void setServerTimeZoneConfig(String serverTimeZoneId)
      Sets the serverTimeZoneConfig attribute.
      serverTimeZoneId - configuration to be set, unless it is null or empty string, in which case ignored.
      See Also:
      • FTPClientConfig
    • setShortMonthNamesConfig

      public void setShortMonthNamesConfig(String shortMonthNames)
      Sets the shortMonthNamesConfig attribute
      shortMonthNames - configuration to be set, unless it is null or empty string, in which case ignored.
      See Also:
      • FTPClientConfig
    • setRetriesAllowed

      public void setRetriesAllowed(String retriesAllowed)
      Defines how many times to retry executing FTP command before giving up. Default is 0 - try once and if failure then give up.
      retriesAllowed - number of retries to allow. -1 means keep trying forever. "forever" may also be specified as a synonym for -1.
    • getRetriesAllowed

      public int getRetriesAllowed()
    • getSystemTypeKey

      public String getSystemTypeKey()
      Returns the systemTypeKey.
    • getDefaultDateFormatConfig

      public String getDefaultDateFormatConfig()
      Returns the defaultDateFormatConfig.
    • getRecentDateFormatConfig

      public String getRecentDateFormatConfig()
      Returns the recentDateFormatConfig.
    • getServerLanguageCodeConfig

      public String getServerLanguageCodeConfig()
      Returns the serverLanguageCodeConfig.
    • getServerTimeZoneConfig

      public String getServerTimeZoneConfig()
      Returns the serverTimeZoneConfig.
    • getShortMonthNamesConfig

      public String getShortMonthNamesConfig()
      Returns the shortMonthNamesConfig.
    • getTimestampGranularity

      public FTPTask.Granularity getTimestampGranularity()
      Returns the timestampGranularity.
    • setTimestampGranularity

      public void setTimestampGranularity(FTPTask.Granularity timestampGranularity)
      Sets the timestampGranularity attribute
      timestampGranularity - The timestampGranularity to set.
    • setSiteCommand

      public void setSiteCommand(String siteCommand)
      Sets the siteCommand attribute. This attribute names the command that will be executed if the action is "site".
      siteCommand - The siteCommand to set.
    • getSiteCommand

      public String getSiteCommand()
    • setInitialSiteCommand

      public void setInitialSiteCommand(String initialCommand)
      Sets the initialSiteCommand attribute. This attribute names a site command that will be executed immediately after connection.
      initialCommand - The initialSiteCommand to set.
    • getInitialSiteCommand

      public String getInitialSiteCommand()
    • getGranularityMillis

      public long getGranularityMillis()
    • setGranularityMillis

      public void setGranularityMillis(long granularity)
    • setEnableRemoteVerification

      public void setEnableRemoteVerification(boolean b)
      Whether to verify that data and control connections are connected to the same remote host.
      b - boolean
      Ant 1.8.0
    • getEnableRemoteVerification

      public boolean getEnableRemoteVerification()
    • checkAttributes

      protected void checkAttributes() throws BuildException
      Checks to see that all required parameters are set.
      BuildException - if the configuration is not valid.
    • execute

      public void execute() throws BuildException
      Runs the task.
      execute in class Task
      BuildException - if the task fails or is not configured correctly.
    • createClasspath

      public Path createClasspath()
    • setupFTPDelegate

      protected void setupFTPDelegate()
    • log

      void log(String msg, int level)