Where to configure platform version alignment rules?

If I have an included java-platform build (e.g. ‘./platform/build.gradle.kts’) for my root project (‘./build.gradle.kts’), and that platform depends on a third-party Maven BOM (e.g. “org.springframework.boot:spring-boot-dependencies”), does it makes sense to declare a ComponentMetadataRule to align the versions of that imported BOM in my included and consumed platform, or do I need to apply the rule to the root project?

It’d be handy if I could do it once in the platform, and have it apply to all projects that consume that platform.

For example…

‘platform/build.gradle.kts’:

plugins {
    `java-platform`
}

javaPlatform {
    allowDependencies()
}

dependencies {
    components.all<SpringBomAlignmentRule>()
    api(platform("org.springframework.boot:spring-boot-dependencies:3.0.3"))
}

abstract class SpringBomAlignmentRule : ComponentMetadataRule {
	override fun execute(ctx: ComponentMetadataContext) {
		ctx.details.run {
			when (id.group) {
				"org.springframework" ->
					belongsTo(
						"org.springframework:spring-framework-bom:${id.version}",
						false
					)
				"org.springframework.boot" ->
					belongsTo(
						"org.springframework.boot:spring-boot-dependencies:${id.version}",
						false
					)
			}
		}
	}
}

Just giving this a bump. If someone at Gradle or otherwise could provide guidance on whether adding such rules to platform projects makes sense, I’d be happy to submit a documentation PR about it.

What’s not clear to me is whether the rule would apply to the projects that consume the platform, or if there are any gotchas that would make doing so not a best practice.

Otherwise I’d think imported platform version alignment in a platform project would be a common use case for BOMs such as Spring’s, Spring Boot’s, Jackson’s, JUnit’s, etc. I wouldn’t think you’d typically want any other behavior for them, as those projects are released as versioned dependency sets.