I'm trying to upload a debug apk file to the server by Gradle. I'm using a special name for it, smth like "demo-testing.apk" or "demo-first.apk".
class Apk extends DefaultTask {
String apkName
@TaskAction
void uploadApk() {
exec {
commandLine(
"cmd",
"-c",
"curl -F \"demo${apkName}.apk=" +
"@${DEFAULT_BUILD_DIR_NAME}/outputs/apk/debug/app-debug.apk\" " +
"https://URL"
)
}
}
}
tasks.register("first", Apk) {
group = 'apkUploads'
description = 'Uploads first apk'
apkName = '-first'
}
But it doesn't execute(with proper URL in the command line arguments) due to this exception:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method exec() for arguments [Apk$_uploadApk_closure1@58ed1
b0a] on task ':first' of type Apk.
Can someone please tell me what I'm doing wrong?
所以感谢上面的评论,我应该调用project.exec
而不是exec
并且它起作用了
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.