Skip to content

Avoid invoking Task.project at execution time in ShadowSource - #37246

Open
noojung wants to merge 1 commit into
spring-projects:mainfrom
noojung:task/avoid-task-project
Open

Avoid invoking Task.project at execution time in ShadowSource#37246
noojung wants to merge 1 commit into
spring-projects:mainfrom
noojung:task/avoid-task-project

Conversation

@noojung

@noojung noojung commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Currently, running the build with --warning-mode=all reports the following deprecation warning:

$ ./gradlew clean build --warning-mode all

> Task :spring-core:javapoetSource
Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 10. This API is incompatible with the configuration cache, which will become the only mode supported by Gradle in a future release. Consult the upgrading guide for further information: https://docs.gradle.org/9.7.1/userguide/upgrading_version_7.html#task_project

ShadowSource currently invokes Task.project at execution time — to run an ArtifactResolutionQuery for source artifacts, and to call Project.sync() and Project.zipTree(). Gradle deprecates this and will reject it in Gradle 10.

This PR injects FileSystemOperations and ArchiveOperations in place of Project, and replaces the List<Configuration> input with a ConfigurableFileCollection populated at configuration time from an ArtifactView that reselects the sources variant. That also removes the last task state that could not be serialized into the configuration cache.

Reselecting the variant requires module metadata, so javapoet and objenesis in spring-core now use transitive = false instead of the @jar artifact-only notation, which skips metadata entirely. The artifacts resolved for the repack jars are unchanged.

However, ArtifactView.ViewConfiguration#withVariantReselection() is still @Incubating in Gradle 9.7.1 and has no stable equivalent.

Reference: https://docs.gradle.org/9.7.1/userguide/upgrading_version_7.html#task_project

ShadowSource invoked Task.project at execution time to resolve source
artifacts and perform file operations, which Gradle 10 will reject.

Inject FileSystemOperations and ArchiveOperations instead of accessing
Project, and replace the Configuration input with an ArtifactView-backed
ConfigurableFileCollection to support the configuration cache.

Also update the javapoet and objenesis dependencies in spring-core to use
'transitive = false' instead of '@jar' so that module metadata is preserved
during sources variant reselection.

Signed-off-by: Hyunwoo Jung <hyunwoojung@kakao.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 7, 2026
@sbrannen sbrannen added the type: task A general task label Sep 7, 2026
@sbrannen
sbrannen requested a review from bclozel September 7, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants