Skip to content

Conversation

@jaxxnitt
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 26, 2025
@jaxxnitt jaxxnitt force-pushed the deprecate-bootArchives-config branch from 5527b30 to 75267a3 Compare October 26, 2025 14:11
@wilkinsona
Copy link
Member

wilkinsona commented Oct 27, 2025

Thanks for the proposal.

I believe that the Gradle team consider the use of afterEvaluate to be a code smell. As such, we wouldn't want to accept these changes as they are. Can you please explain why they're necessary beyond avoiding "illegal task mutation"?

Ensuring Gradle 9+ compatibility.

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.

Preventing deprecation noise during automated test runs.

I don't think we've seen such noise. Can you please share an example?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Oct 27, 2025
@jaxxnitt jaxxnitt force-pushed the deprecate-bootArchives-config branch from 044c031 to 98a436e Compare October 27, 2025 12:35
@jaxxnitt
Copy link
Author

jaxxnitt commented Oct 27, 2025

I believe that the Gradle team consider the use of afterEvaluate to be a code smell. As such, we wouldn't want to accept these changes as they are.

Thanks Andy — agreed.
The afterEvaluate block was added only to avoid IllegalTaskMutationException when wiring assemble with BootJar and BootWar.

I’ve now removed it and used withPlugin("java") / withPlugin("war") + configureEach, which keeps configuration lazy and avoids any illegal mutation during evaluation.

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 with Gradle 9.x without these changes.

You’re right — the plugin still works fine on Gradle 9.x.
The intent was forward compatibility since Gradle has deprecated the archives configuration (which bootArchives mirrors) and plans to remove it in Gradle 10.

References:

https://docs.gradle.org/current/userguide/upgrading_version_9.html#deprecated_archives_configuration

[https://github.com/gradle/gradle/issues/15639]

I don't think we've seen such noise. Can you please share an example?

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+).
It wasn’t based on actual noise in CI, just an attempt to keep test output cleaner.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Oct 27, 2025
Copy link
Member

@wilkinsona wilkinsona left a 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.

Comment on lines +126 to +130
project.getPluginManager().withPlugin("java", plugin -> {
project.getTasks().named("assemble").configure(assemble -> {
project.getTasks().withType(BootJar.class).configureEach(assemble::dependsOn);
});
});
Copy link
Member

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.

Comment on lines +132 to +136
project.getPluginManager().withPlugin("war", plugin -> {
project.getTasks().named("assemble").configure(assemble -> {
project.getTasks().withType(BootWar.class).configureEach(assemble::dependsOn);
});
});
Copy link
Member

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.

Comment on lines +160 to +162
.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.");
Copy link
Member

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.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants