Open jansorg opened 4 months ago
Thanks for spotting this. I'll look into it ...
🤔 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.
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)
}
}
}
}
}
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.
Describe the bug
Using Gradle with configuration cache enabled, I'm seeing these warnings for the Verify task:
Sample build script
Snippets which may help:
gradle.properties: