0

I want to write very simple task, which downloads a zip and unzip current file.

open class HelmInstall : DefaultTask() {

    @Input
    var downloadUrl = "https://someZip"

    @Input
    var destDir: String = ".helm"


    @TaskAction
    fun start() {
        val dir = project.buildDir.resolve(destDir)
        /*
        some logic by upload from downloadUrl 
        */
        val file = dir.resolve("nameOfApp").write(text)

        helm.set(file )

    }

    @OutputFile
    var helm: RegularFileProperty = project.objects.fileProperty()

}

It builds, but when I try apply my task I have error

Caused by: org.gradle.api.InvalidUserDataException: No value has been specified for property 'helm'.
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:71)

how should I declare helm so that there is no error? And maybe you now good helm plugin or client? And useful lib for download and unzip file?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Tim
  • 155
  • 1
  • 3
  • 13
  • How do you configure the task in the build file? Looks like you haven't set value to the helm property. There is a pretty [good documentation](https://docs.gradle.org/current/userguide/custom_tasks.html) with lots of samples of creating an configuring custom gradle tasks. – esentsov Nov 24 '20 at 19:56
  • if i need chnage some input value i write in my build.gradle.kts some like tasks.helmInstall{ downloadUrl = "otherUrl" } – Tim Nov 25 '20 at 08:21
  • but I will only do this if I need to change the default values. I usually won't do this – Tim Nov 25 '20 at 08:23
  • `helm` property should be set before the task execution, on configuration phase. – esentsov Nov 25 '20 at 14:55
  • how explain gradle, that it property will be set, when task executed? And AFTER execute task it can use it in other tasks by Provider? – Tim Nov 25 '20 at 23:57
  • Please check out [this link](https://discuss.gradle.org/t/can-i-update-a-task-property-during-execution-step/34909/3) – esentsov Nov 26 '20 at 06:52

0 Answers0