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

Gradle warns about configuration cache problems of Verify #403

Open
jansorg opened this issue Jul 23, 2024 · 4 comments
Open

Gradle warns about configuration cache problems of Verify #403

jansorg opened this issue Jul 23, 2024 · 4 comments
Labels

Comments

@jansorg
Copy link

jansorg commented Jul 23, 2024

Describe the bug

Using Gradle with configuration cache enabled, I'm seeing these warnings for the Verify task:

- Task `:verifyLspBinary` of type `de.undercouch.gradle.tasks.download.Verify`: cannot serialize Gradle script object references as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:verifyLspBinary` of type `de.undercouch.gradle.tasks.download.Verify`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

Sample build script

Snippets which may help:

     val verifyLspBinary by registering(Verify::class) {
            algorithm("sha256")
            src(myPath)
            checksum("my checksum")
        }

gradle.properties:


org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
@michel-kraemer
Copy link
Owner

Thanks for spotting this. I'll look into it ...

@michel-kraemer
Copy link
Owner

🤔 I'm unable to reproduce this. I've created a new directory and copied the build.gradle.kts file from examples/kotlin/verify and your gradle.properties into it. I then ran gradle verifyFile --configuration-cache two times. The first time it prints Calculating task graph as no cached configuration is available for tasks: verifyFile and the second time it says Reusing configuration cache. Everything seems to work as expected.

I also checked the source code and the Verify class does not keep Project as the error message suggests. It only keeps ProjectLayout which actually can be used with the configuration cache.

You did not say which version of gradle-download-task you're using. Please make sure to use the latest version. If the problem persists, please try to create a minimal reproducing example. That would help a lot. Thanks.

@jansorg
Copy link
Author

jansorg commented Jul 26, 2024

Thanks!
I was also unable to reproduce this with tasks of type Download or Verify.
I only managed to reproduced the same or a similar problem with task download of the following snippet, using a doLast {...} block.

Demo repository at https://github.com/jansorg/gradle-download-bug-demo

Output for ./gradlew download:

> Task :download
Download https://httpbin.org/json

FAILURE: Build failed with an exception.

* What went wrong:
Configuration cache problems found in this build.

1 problem was found storing the configuration cache.
- Task `:download` of type `org.gradle.api.DefaultTask`: cannot serialize object of type 'org.gradle.api.internal.project.DefaultProject', a subtype of 'org.gradle.api.Project', as these are not supported with the configuration cache.
  See https://docs.gradle.org/8.9/userguide/configuration_cache.html#config_cache:requirements:disallowed_types

See the complete report at file:///Work/source/download-bug-demo/build/reports/configuration-cache/10to7kfptf6o37lcbk57uncn6/dwksd2tnsgpn78k9y64ku1mq/configuration-cache-report.html

build.gradle.kts:

import de.undercouch.gradle.tasks.download.Download
import de.undercouch.gradle.tasks.download.Verify
import org.gradle.internal.impldep.org.apache.commons.codec.digest.DigestUtils
import org.jetbrains.kotlin.daemon.common.toHexString

plugins {
    kotlin("jvm") version "2.0.0"
    id("de.undercouch.download") version "5.6.0"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test"))
}

tasks.test {
    useJUnitPlatform()
}

kotlin {
    jvmToolchain(17)
}

allprojects {
    tasks {
        val downloadJson by registering(Download::class) {
            src("https://httpbin.org/json")
            dest(layout.buildDirectory.file("my-file.json"))
        }

        val verifyJson by registering(Verify::class) {
            dependsOn(downloadJson)

            algorithm("sha256")
            src(layout.buildDirectory.file("my-file.json"))
            checksum("bab3dfd2a6c992e4bf589eee05fc9650cc9d6988660b947a7a87b99420d108f9")
        }

        create("download") {
            doLast("download JSON file") {
                download.run {
                    src("https://httpbin.org/json")
                    dest("other.json")
                    onlyIfModified(true)
                }
            }
        }
    }
}

Copy link

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in two weeks if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

2 participants