I am trying to learn how to use “platforms” to align dependency versions between projects in a multi-project setup. So far I’ve seen:
- https://docs.gradle.org/6.2.1/userguide/platforms.html
- https://docs.gradle.org/6.2.1/userguide/dependency_management_terminology.html#sub::terminology_platform
- https://docs.gradle.org/6.2.1/userguide/dependency_version_alignment.html#sec:virtual_platform
- https://docs.gradle.org/6.2.1/userguide/dependency_constraints.html#sec:adding-constraints-transitive-deps
- https://docs.gradle.org/6.2.1/userguide/java_platform_plugin.html
- … and some more external sites trying to find examples, such as https://dzone.com/articles/gradle-goodness-use-bill-of-materials-bom-as-depen
I understand how I can declare constraints within a project. I think I also understand how to use BOMs for this purpose. However, I would like to use an “enforced platform
project” for this purpose and I don’t understand a number of things here:
- Do I have to use a “java platform” plugin or not? We have non-Java projects. Our configurations don’t quite fit into the “api” and “runtime” buckets.
- Even if we were all Java, for any one project, we can’t have separate versions for its “api” and for its “runtime”. While I do understand the level of control this may offer in some cases, I do not understand how are these meant to work together, to make sure that the project gets the specified dependency.
-
How does Gradle know which configurations’ constraints to match between the project using the platform and the platform specifications? I think I saw the examples defining “api” and other constraints in the platform and I “understand” that the projects would reference this by declaring
api platform(project(':platform'))
. I hope Gradle isn’t trying to match “api” to “api” by simple name. I’d need multiple different dependency configurations to all be aligned against the same single platform “configuration” or whatever it is called.
In general, I didn’t find enough information to feel confident about what this does or how it works. Can someone fill in the blanks or point me to some document showing more examples and details than the above?
Thanks!