Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a provider for property checksum #402

Open
jansorg opened this issue Jul 23, 2024 · 1 comment
Open

Allow a provider for property checksum #402

jansorg opened this issue Jul 23, 2024 · 1 comment
Assignees

Comments

@jansorg
Copy link

jansorg commented Jul 23, 2024

Is your feature request related to a problem? Please describe.

The workflow is like this

  1. Download a manifest file containing file URL and checksum
  2. Download the file
  3. Verify the file with the manifest's checksum

Describe the solution you'd like

Because checksum is a plain string I need to assign a value when the task is configured.
But the manifest's checksum is only available after the download of the manifest file.

Describe alternatives you've considered

Seems to work, but not very nice:

checksum("dummy")
doFirst {
  checksum(checksumFromManifest)
}
@michel-kraemer
Copy link
Owner

Thanks for reporting this. You are right that lazy configuration is not properly implemented in gradle-download-task yet. As a matter of fact, the properties that do allow it are almost always evaluated during initialization, which is too early for your use case. I could make it so that the checksum property is evaluated later but I'd rather not mix different approaches in one version.

I'll keep this issue open and implement lazy task configuration properly in the next major version of gradle-download-task.

In the meantime, you can use the verifyChecksum extension to achieve the same thing:

task downloadFile(type: Download) {
    src 'http://yourserver.com/file.dat'
    dest layout.buildDirectory
}

task downloadChecksumFile(type: Download) {
    src 'http://yourserver.com/file.dat.md5'
    dest layout.buildDirectory
}

task verifyFile(dependsOn: [downloadChecksumFile, downloadFile]) {
    doLast {
        verifyChecksum.run {
            src downloadFile.outputs.files.singleFile
            algorithm 'MD5'
            checksum downloadChecksumFile.outputs.files.singleFile.text
        }
    }
}

I hope this helps. Let me know if you have questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants