Skip to content

Conversation

@mikewacker
Copy link
Contributor

Fixes #452

Usage Notes

With the configuration cache enabled, users will also need to capture dockerCompose in a local variable. Example (Kotlin):

tasks.named<Test>("test") {
    val dockerCompose = dockerCompose
    doFirst {
        dockerCompose.exposeAsEnvironment(this@named)
    }
}

Without the val dockerCompose = dockerCompose line, you would get an error like this:

1 problem was found storing the configuration cache.
- Task `:lib:test` of type `org.gradle.api.tasks.testing.Test`: cannot serialize Gradle script object references as these are not supported with the configuration cache.
  See https://docs.gradle.org/9.1.0/userguide/configuration_cache_requirements.html#config_cache:requirements:disallowed_types

Notes

The code comments have an important corollary for the tests.

  • Calling a task action directly (i.e., f.project.tasks.composeUp.up()) does not complete the task.
  • Corollary: Tests always call composeSettings.servicesInfos before the composeUp task is "completed."

Additional Testing

Uses example.zip, which calls exposeAsSystemProperties() directly.

  1. ./gradlew publishToMavenLocal (for the plugin)
  2. ./gradlew clean build (for the example)

@augi augi force-pushed the mikewacker/config-cache-expose branch from aab0973 to b018a12 Compare October 31, 2025 11:33
@augi augi merged commit 637f3dc into avast:main Oct 31, 2025
1 check passed
@mikewacker mikewacker deleted the mikewacker/config-cache-expose branch November 2, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration cache incompatibility when using dockerCompose.exposeAsSystemProperties in doFirst block

2 participants