Managing transitive dependency versions

I have 3 gradle projects: Project-1, Project-2, Project-3. Project-1 and Project-2 are Java libraries, Project-3 is a consumer of these libraries. Both Project-1 and Project-2 have a dependency on Module-A. However, for every one of them I want to be able to specify a list of exact versions that they are compatible with. For example, Project-1 is compatible and tested with Module-A, versions 1 and 2, but Project-2 is compatible with Module-A, versions 2 and 3. I want to be able to specify these requirements in the build configuration of each project. These dependencies can be impelementation only or even compileOnly.

When Project-3 consumes libraries built by Project-1 and Project-2, I want to make sure that Module-A is resolved to the latest version that is explicitly listed in both Project-1 and Project-2. Otherwise, I would like to get an error at the build step, that no satisfying dependency resolution can be found. Ideally, I would like to be able to explicitly specify version of Module-A in Project-3 Gradle build and receive an error if it’s not compatible with any of Project-1 or Project-2.

Project-1 and Project-2 artifacts are consumed from and uploaded to a local Maven repository using Maven plugin.