How to upload folder contents to FTP server using Gradle

build.gradle, gradle

Solution

ftpAntTask is fairly simple to use.

buildscript {
    repositories {
        mavenCentral()
    }
}
repositories{
    mavenCentral()
}

configurations {
    ftpAntTask
}

dependencies {
    ftpAntTask("org.apache.ant:ant-commons-net:1.8.4") {
        module("commons-net:commons-net:1.4.1") {
            dependencies "oro:oro:2.0.8:jar"
        }
    }
}

task ftp << {
    ant {
        taskdef(name: 'ftp',
                classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                classpath: configurations.ftpAntTask.asPath)
        ftp(server: "(removed)", userid: "(removed)", password: "(removed)", remoteDir: "(removed)") {
            fileset(dir: "(removed)") {
                include(name: "(removed)")
            }
        }
    }
}

(This example was made from How to FTP a file from an Android Gradle build?)

Problem

I am new to gradle and I don't know how to upload my /bin folder contents to the FTP server. Tried to find solution in internet, but they didn't help to me. My build.gradle file is as follows: ``` apply plugin: 'java' sourceCompatibility = 1.6 version = '1.0' repositories { mavenCentral() } dependencies { compile 'org.apache.httpcomponents:httpclient:4.3.3' compile fileTree(dir: 'lib', include: '*.jar') compile 'org.apache.directory.studio:org.dom4j.dom4j:1.6.1' compile 'jaxen:jaxen:1.1.4' testCompile group: 'junit', name: 'junit', version: '4.11' } build.doLast { copy { into 'bin' from 'build/libs' } } ``` Now I want to write task which will upload /bin folder contents to the FTP server. Any help would be appreciated. Thanks in advance

Original source

Related problems