code: public void uploadDirectoryWithRetries(final String ftpServer, final String username, final String password,
                                             final String sourceDirectory, final String targetDirectory,
                                             final int maxRetryCount) throws MojoExecutionException {
          int retryCount = 0;
          while (retryCount < maxRetryCount) {
              retryCount++;
              log.info(UPLOAD_START + ftpServer);
              if (uploadDirectory(ftpServer, username, password, sourceDirectory, targetDirectory)) {
                  log.info(UPLOAD_SUCCESS + ftpServer);
                  return;
              } else {
                  log.warn(String.format(UPLOAD_FAILURE, retryCount, maxRetryCount));
              }
          }
          // Reaching here means all retries failed.
          throw new MojoExecutionException(String.format(UPLOAD_RETRY_FAILURE, maxRetryCount));
      }
docs: Upload directory to specified FTP server with retries.
  
  @param ftpServer
  @param username
  @param password
  @param sourceDirectory
  @param targetDirectory
  @param maxRetryCount
  @throws MojoExecutionException