I'm trying to get an argument from the command line using a Gradle task:
class myApk extends DefaultTask {
@Option(option="apkName", description="apkName for your file")
String apkName
@TaskAction
void uploadApk() {
def arg = "curl -F \"demo${apkName}.apk=" +
"@${project.projectDir}\\app\\build\\outputs\\apk\\debug\\app-debug.apk\" " +
"https://URL"
project.exec {
commandLine("cmd", "/c", arg)
}
}
}
task uploadApk(type: myApk) { }
But after typing gradle uploadApk --apkName=foo
in the terminal I get this kind of exception:
Problem configuring task :app:uploadApk from command line.
> Unknown command-line option '--apkName'.
P.S. I've read this topic(How to pass arguments from command line to gradle), but it doesn't seem helpful for this problem;(