This is a question about the java-platform plugin ...
# community-support
t
This is a question about the java-platform plugin (or really, just about dependency constraints), and how that interacts or doesn't with variants. for Gradle projects with test fixtures (more generally: additional variants), do we need to declare the constraint multiple times?
j
No, the platform is a separate "node" in the graph. It is one collection of constraint. What you need to do is "using" that "node" (component) in all the places you want to use the constraints. That is, if you define the dependency on the platform you need:
Copy code
implementation(platform(project(":platform")))

testFixturesImplementations(platform(project(":platform")))

customFeatureImplementation(platform(project(":platform")))
If the custom scopes are somehow setup to inherit from
implementation
, you may inherit the declaration and may not need to re-declare it.
A pattern I use in certain project setups where "a platform should be used everywhere but is not published" is to add a configuration called
internal
from which all classpath configuration inherit to use the platform everywhere.
This pattern is also implemented in the "jvm-dependency-conflict-resolution" plugin (
consistentResolution.platform(...)
): https://gradlex.org/jvm-dependency-conflict-resolution/#consistent-resolution-block
t
thanks Jendrik. That is also my understanding. I was asking because I'm observing what I believe are bugs in gradle's dependency resolution. But I asked in case I was doing something wrong -- I think that I'm not.
👍 1