okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Add dependency alignment metadata to Gradle metadata

Open tbroyer opened this issue 2 months ago • 3 comments

Currently, ensuring that versions are aligned between OkHttp dependencies in a Gradle project requires explicitly adding a platform dependency to the okhttp-bom.

Ideally, each module listed in okhttp-bom should itself depend on okhttp-bom as a platform dependency to transitively contribute those dependency constraints downstream.

See https://blog.gradle.org/alignment-with-gradle-module-metadata

tbroyer avatar Sep 25 '25 11:09 tbroyer

That's an interesting approach as opposed to adding each constraint individually.

This came up recently in #8903.

JakeWharton avatar Sep 25 '25 16:09 JakeWharton

They link to Jackson and Junit. I can't see where Jackson does this because maven.

For junit https://github.com/junit-team/junit-framework/blob/b7eddfc1d953282c2e2cf428a425e047a96b6ebf/junit-jupiter-api/junit-jupiter-api.gradle.kts it's just

	api(platform(project(":junit-bom")))

yschimke avatar Oct 11 '25 06:10 yschimke

Fwiw, Jackson uses a Maven plugin to publish Gradle Module Metadata : https://github.com/gradlex-org/gradle-module-metadata-maven-plugin

Otherwise yes it's only a matter of adding a platform dependency on the BOM into each module listed in the BOM (creating a form of circular dependency cycle)

tbroyer avatar Oct 11 '25 07:10 tbroyer