Say I am building a library A for my company that uses 3 dependencies B, C and D.
Of course the classes of A will be used when A is imported, but most of the time classes from B, C and D are used as well in the new project.
At them moment if I am fetching A from, say, Maven I need to declare again the imports for B, C and D keeping in mind what version of those 3 libs A needs.
Can’t I declare which versions A needs for B, C and D into some Gradle metadata so that the new Gradle project knows which dependency is needed and download it from known repositories?
Eventually being able to override the version of the imports would be great as well!
It’s not really clear what you’re asking here. It sounds like you want basic transitive dependency management, which has been a feature of Gradle since the beginning. What you’re asking for is just how Gradle works, unless A was published in a broken state, but there’s not enough information here to determine that.
If I understood correctly, you publish a some library internally (which you called A) that depends on some other things (B, C, D). Now you’re asking if it’s possible to declare those dependencies in A’s published artifact, right? That’s basic transitive dependency management as @jjustinic said, and should work out of the box - at least if you publish to a Maven repository. If it doesn’t, it would help to see your build.gradle.