1

I have a structure in an android app using gradle like,

module A:
    dependencies{ 
    module B
    }
module B:{
   dependencies{
   module C
   }
module C:{
   dependencies{
   module D
   }

Are these dependencies transitive? How can I access the classes of module D in module A directly?

Nishita
  • 870
  • 1
  • 9
  • 33

1 Answers1

1

edit : same thing with D

C is a transitive dependency of A

Your ide should allow you to directly use classes of C in A but it's a bad practice. If A really needs C, it should declare it as a direct dependency

module A:
    dependencies { 
       module B
       module C
       module D
}
ToYonos
  • 16,469
  • 2
  • 54
  • 70
  • done, same thing, just add `D` as a dependency if `A` – ToYonos Sep 06 '18 at 10:30
  • No, I want to know if it can be done using transitivity. – Nishita Sep 06 '18 at 10:31
  • It will work but if a module really needs a dependency, it should declare it – ToYonos Sep 06 '18 at 10:35
  • Why is this considered a bad practice? – Nishita Sep 06 '18 at 11:06
  • It explained in these 2 links : https://softwareengineering.stackexchange.com/questions/320128/is-it-better-to-rely-on-transitive-dependencies-or-explicitly-declare-them/320151 https://stackoverflow.com/questions/47260901/should-i-rely-on-transitive-dependencies-in-maven-if-they-come-from-other-sub-mo – ToYonos Sep 06 '18 at 11:52