我試圖在Gradle構建之後FTP簽名的APK。我已經添加了新的構建配置,將簽署APK,但我堅持試圖找出如何調用FTP任務。如何通過Android Gradle構建FTP文件?
我在發現了一個正式的示例,但它抱怨說它無法解析org.apache.ant的依賴關係:ant-commons-net:1.8.4。所以顯然我在這裏忽略了一些明顯的東西,比如在哪裏放置給定的jar文件或引用它,雖然我認爲maven會處理這種事情?
僅供參考,這裏是連接樣品從而未能與有關的依賴消息:
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: "[email protected]") {
fileset(dir: "htdocs/manual")
}
}
}
這失敗的消息:
> Could not find org.apache.ant:ant-commons-net:1.8.4.
這裏是我的完整gradle.build文件,刪除了一些敏感信息:
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)")
}
}
}
}
謝謝,但是,我確實在我的構建文件中。我更新了我的問題。 –
不,您剛剛爲您的gradle插件(build腳本部分中的存儲庫塊)聲明瞭一個存儲庫,您需要在頂層上另一個存儲庫,就像我在代碼段中完成的那樣。有計劃使未來更容易應用插件並使其更容易。 –
你是對的......修復它。謝謝 –