Skip to content

Instantly share code, notes, and snippets.

@koizuss
Created November 10, 2011 13:59
Show Gist options
  • Save koizuss/1354906 to your computer and use it in GitHub Desktop.
Save koizuss/1354906 to your computer and use it in GitHub Desktop.
gradle antでftp
repositories {
mavenCentral()
}
configurations {
ftpAntTask
}
dependencies {
ftpAntTask("org.apache.ant:ant-commons-net:1.8.2") {
module("commons-net:commons-net:1.4.1") {
dependencies "oro:oro:2.0.8:jar"
}
}
}
task 'ftp-get' << {
ant {
taskdef(name: 'ftp',
classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
classpath: configurations.ftpAntTask.asPath)
ftp(action: 'get', server: 'ftpserver', userid: 'ftpuser', password: 'ftppassword', verbose: true, depends: true, binary: true) {
fileset(dir: 'src'){
include(name: '**/*')
}
}
}
}
// http://gradle.org/current/docs/userguide/organizing_build_logic.html
// http://www.jajakarta.org/ant/ant-1.5/docs/ant-1.5/j/docs/manual/OptionalTasks/ftp.html
@jfbibeau
Copy link

jfbibeau commented Aug 10, 2017

In case anyone is having trouble getting this working, you can use the ant native get task and achieve something in a much simpler way. No extra dependencies, works out of the box:

      ant {
        get(src: "ftp://<hostname>/remote/path/to/file.jar", dest: "/local/path/to/file", username: 'anonymous', password: 'anonymous')
      }

@Baneeishaque
Copy link

how to exclude some directory from ftp uploading?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment