A platform may define constrains by depending on another platform or on a Maven bom. If the constraints in that transitive platform or bom are unwanted, excluding it helps.
As far as I can tell, this doesn’t work as you would expect due to a bug in the Kotlin DSL. The DSL seems to think the receiver should be a Configuration
when it’s actually an ExternalModuleDependency
. You can work around that with a cast:
dependencies {
implementation(platform("com.alibaba.csp:sentinel-parameter-flow-control")) {
(this as ExternalModuleDependency).exclude("com.alibaba.middleware", "metrics-integration")
}
}
Note that this particular exclude may have no effect if metrics-integration
is a constraint rather than a transitive platform or bom dependency. When importing a bom, allow a bom that it imports to be excluded · Issue #317 · spring-gradle-plugins/dependency-management-plugin · GitHub discusses a problem where such an exclude is useful and effective.