如何从 Android Gradle 构建 FTP 文件? [英] How to FTP a file from an Android Gradle build?

查看:23
本文介绍了如何从 Android Gradle 构建 FTP 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Gradle 构建后对已签名的 APK 进行 FTP 传输.我已经添加了将签署 APK 的新构建配置,但我一直在试图弄清楚如何调用 FTP 任务.

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

我在 第 59.6 节 找到了一个官方样例,但是它抱怨它无法解决依赖关系 org.apache.ant:ant-commons-net:1.8.4.所以显然我在这里遗漏了一些明显的东西,比如在哪里放置给定的 jar 文件或引用它,尽管我认为 maven 会处理这种事情?

I found an official looking sample at section 59.6, however it complains that it cannot resolve dependency org.apache.ant:ant-commons-net:1.8.4. So apparently I'm missing something obvious here, like where to put a given jar file or reference it, although I thought maven would handle this sort of thing?

作为参考,这里是链接示例,它失败并显示有关依赖项的消息:

For reference, here is the linked sample which fails with a message about the dependency:

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")
        }
    }
}

失败并显示以下消息:

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

这是我完整的 gradle.build 文件,删除了一些敏感信息:

Here is my complete gradle.build file, with some sensitive 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)")
            }
        }
    }
}

推荐答案

您尚未声明可用于解析已声明工件的存储库.尝试将以下代码段添加到您的 build.gradle 文件中:

You havn't declared a repository that can be used to resolve the declared artifacts. Try adding the following snippet to your build.gradle file:

repositories{
    mavenCentral()
}

干杯,

勒内

这篇关于如何从 Android Gradle 构建 FTP 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆