-
Couldn't load subscription status.
- Fork 41.6k
Deprecate bootArchives configuration and migrate assemble task dependencies #47804
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
base: main
Are you sure you want to change the base?
Deprecate bootArchives configuration and migrate assemble task dependencies #47804
Conversation
5527b30 to
75267a3
Compare
|
Thanks for the proposal. I believe that the Gradle team consider the use of
We test the plugin against Gradle 9.x and believe it to be compatible. If this change is necessary with Gradle 9, please provide an example that fails with Gradle 9.x without these changes.
I don't think we've seen such noise. Can you please share an example? |
Signed-off-by: jaxxnitt <[email protected]>
Signed-off-by: jaxxnitt <[email protected]>
Signed-off-by: jaxxnitt <[email protected]>
Signed-off-by: jaxxnitt <[email protected]>
044c031 to
98a436e
Compare
Thanks Andy — agreed. I’ve now removed it and used withPlugin("java") / withPlugin("war") + configureEach, which keeps configuration lazy and avoids any illegal mutation during evaluation.
You’re right — the plugin still works fine on Gradle 9.x. References: https://docs.gradle.org/current/userguide/upgrading_version_9.html#deprecated_archives_configuration [https://github.com/gradle/gradle/issues/15639]
The suppression flag (spring.boot.tests.active=true) was added defensively, in case Gradle emits warnings for deprecated configurations (which can appear when running with --warning-mode all on Gradle 9+). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I've left a few comments for your consideration.
Beyond those, I think this change will break the functionality provided by SinglePublishedArtifact where only the uber war or uber jar, and not both, is built/published.
It's also worth nothing that Gradle itself is still using the archives configuration internally. Furthermore, I don't think that their deprecation of archives necessarily forces a deprecation of bootArchives. It probably makes sense at some point, but it doesn't appear to be necessary at the moment. Nor, as far as I can tell, will it become necessary with Gradle 10 either.
| project.getPluginManager().withPlugin("java", plugin -> { | ||
| project.getTasks().named("assemble").configure(assemble -> { | ||
| project.getTasks().withType(BootJar.class).configureEach(assemble::dependsOn); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All BootJar tasks should not be depended on by assemble. At most, it should be only the bootJar task created by JavaPluginAction.
| project.getPluginManager().withPlugin("war", plugin -> { | ||
| project.getTasks().named("assemble").configure(assemble -> { | ||
| project.getTasks().withType(BootWar.class).configureEach(assemble::dependsOn); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All BootWar tasks should not be depended on by assemble. At most, it should be only the bootWar task created by WarPluginAction.
| .warn("The 'bootArchives' configuration is deprecated and will be removed in a future release. " | ||
| + "Gradle no longer supports using 'archives' for dependency resolution. " | ||
| + "Spring Boot will migrate to direct task dependencies on 'assemble' instead."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this warning is helpful as a user can't do anything about it.
Added direct assemble dependencies for BootJar and BootWar tasks using afterEvaluate to avoid illegal task mutation.
Deprecated the bootArchives configuration while retaining backward compatibility for existing builds.
Added conditional logging to suppress the deprecation warning during internal plugin tests (spring.boot.tests.active flag).
Updated build.gradle to pass spring.boot.tests.active=true as a system property to all test tasks.
Annotated SpringBootPluginTests.bootArchivesConfigurationsCannotBeResolved with @SuppressWarnings("removal") to prevent test warnings.
Why This Change
Gradle 9 deprecates configuration-based artifact resolution (archives), which the bootArchives configuration depended on.
This update modernizes Spring Boot’s Gradle plugin by:
Ensuring Gradle 9+ compatibility.
Preserving backward compatibility for existing projects.
Preventing deprecation noise during automated test runs.
Testing
All existing tests in SpringBootPluginTests and PackagingDocumentationTests pass successfully.
Verified no IllegalMutationException occurs during plugin application.
No warnings appear when spring.boot.tests.active=true.