"Best practice" for creating Java plaform?

Hi,

I am creating my first platform dependency in Gradle, and it seems to work. However, I am sure I saw something somewhere in the Gradle documentation saying that if I define my platform as:

dependencies {
    constraints {
        api project(':foo')
        api project(':bar')
    }
}

then both modules :foo and :bar should also declare a dependency back to the platform:

dependencies {
    implementation platform(project(':platform'))
    ...
}

I cannot find where I saw this advice now, and so I am wondering if I initially misread something.

Can anyone either confirm or deny this understanding please?
Thanks,
Chris

Edit: I think I might have been remembering this article

Yes, version aligning ist most likely where you have read that. The question simply is, whether you want / need the versions of those modules aligned. If that’s the case, then you should have that dependency, yes, so that if you depend on foo, it automatically adds platform with the same version, the same for bar, then potentially different versions of platform are conflict-resolved and the winner defines the version for both.

1 Like