0

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;(

Lukas Körfer
  • 13,515
  • 7
  • 46
  • 62
memeprincess
  • 318
  • 3
  • 16

1 Answers1

1

Thanks to the comment above, I used -P to work it out

memeprincess
  • 318
  • 3
  • 16