How to FTP file from Android build Gradle?

I am trying to execute an FTP signed APK after building Gradle. I already added a new build configuration that will sign the APK, but I'm stuck trying to figure out how to invoke the FTP task.

I found the official sample in section 59.6 , however it complains that it cannot resolve the org.apache.ant dependency: ant - Net: 1.8.4. Therefore, apparently, I am missing something obvious here, for example, where to put the given jar file or refer to it, although I thought that maven would handle such things?

For reference, here is a related pattern that fails with a dependency message:

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: "ftp.apache.org", userid: "anonymous", password: " me@myorg.com ") { fileset(dir: "htdocs/manual") } } } 

This message is not executed:

 > Could not find org.apache.ant:ant-commons-net:1.8.4. 

Here is my full gradle.build file with confidential information removed:

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android' dependencies { compile files('libs/android-support-v4.jar') } android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 14 targetSdkVersion 17 } signingConfigs { signed { storeFile file("(removed)") storePassword "(removed)" keyAlias "(removed)" keyPassword "(removed)" } } buildTypes { signed { debuggable false jniDebugBuild false signingConfig signingConfigs.signed } } } 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)") } } } } 
+7
source share
2 answers

You have not announced a repository that can be used to resolve claimed artifacts. Try adding the following snippet to the build.gradle file:

 repositories{ mavenCentral() } 

amuses

Renee

+1
source

You can also use the built-in ant get task, which supports FTP, works without external dependencies:

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

All Articles