I created to task to copy and FTP a package

task ftp(dependsOn: "copyApk") {
    doLast {
        ant {
            taskdef(name: 'ftp',
                    classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                    classpath: configurations.ftpAntTask.asPath)
            ftp(server: "ftp.mydomain.com", userid: "ftp.mydomain.com|administrator", password: "adkjadfsid", remoteDir: "download") {
                fileset(dir: "E:/.../download/") {
                    include(name: "my-app.apk")
                }
            }
        }
    }
}

It worked flawlessly for a few years. I recently upgraded Android Studio to Giraffe and a slew of other packages including gradle. The task's script has been changed to the following per Android Studio's recommendation:

tasks.register('ftp') {
    dependsOn "copyApk"
    doLast {
        ant {
            taskdef(name: 'ftp',
                    classname: 'org.apache.tools.ant.taskdefs.optional.net.FTP',
                    classpath: configurations.ftpAntTask.asPath)
            ftp(server: "ftp.mydomain.com", userid: "ftp.mydomain.com|administrator", password: "adkjadfsid", remoteDir: "download") {
                fileset(dir: "E:/.../download/") {
                    include(name: "my-app.apk")
                }
            }
        }
    }
}

When I run the task, I get the following error:

Cannot reference a Gradle script object from a Groovy closure as these are not supported with the configuration cache.

The problematic line is:

ant {

Could anyone offer a tip on how to fix this?

1

There are 1 best solutions below

0
Fhl On

As a workaround you can disable the configuration cache when running your task. E.g.:

./gradlew ftp --no-configuration-cache