Hi everyone.
Welcome back.
In this lecture we are going to learn about the technique to how to transitively have the dependencies
available to the other modules.
So in this case to experiment that one we are going to be working on the module three.
And if you take a look at the module three you will have this file already available.
So what we are going to do is let's open this file and then you will have this code commented out over
there okay let's uncomment this code.
So what this module is going to do.
This is going to be referencing the module two.
So module three is going to reference to module two okay.
And if you go to the build.gradle file you will notice this module two implementation available.
So let's go ahead and uncomment that code.
So once you're done with that what we will do we'll go ahead and refresh the Gradle project.
There you go.
So now with this any code that's available in module two, whatever we have defined in the export section
will be visible to the module three.
So in this case we have client Dtos.
We have not added it.
What we will do we'll do exports comm dot module two dot dtos.
And then we can actually also do the service.
So any classes under this package will be visible to the module three.
Right.
So there are no doubts in that one.
So now let's say we have a specific use case where module three requires a code that's there in module
one.
So it needs a code.
In this case it's going to be module one service.
So module three requires the module one service class.
That's part of the module one.
But as per our dependency tree the module three is only dependent on module right.
So in this case how do we get the dependency that's present in module one.
But if you all can remember module two is actually referencing module one.
Right.
So it has the code available to its specific module.
Right.
Which means module two has access to all the source code.
That's part of the exports in module two.
So now what are the options that we have in order to make sure module three has access to the module
one code.
So in this particular scenario, if you go to the module tools module info file, we can actually transitively
provide that dependency available to module three.
The way you do it is by using the transitive directive.
So in this case let's copy this one.
So I'm going to put it over here.
But what I'm going to do is I'm going to have transitive over here.
So when you do transitive we are actually supplying the module one dependencies also to any other module
that's going to use module two.
So in this case our module three is using module two.
Right.
So in this case you will find this class available over here.
So if you go and open this class and then let's uncomment this class.
So with the code setup that we have which means the module two is transitively providing module one.
This means we are going to be seeing the classes that is available in module one to any other module
that uses module two as a dependency.
So in this case, module three uses module two as a dependency.
Now if you uncomment this code you just need to automatically import the classes.
But I think there is one thing which we need to uncomment in the module three.
So in this case we can uncomment this one.
So this should take care of having this module one also available for resolving that particular file.
So let's go ahead and do a quick refresh.
And then if you go here you will see this import option readily available.
So as soon as you import that one you have the next import that needs to be imported.
And this code compiles fine.
So this is how you transitively provide the dependencies from one module to another.
If you take a look at the module three file, we do not have any reference of module one here, but
still we were able to access the module one code in module three.
So this is all about how do you transitively provide the dependencies to other modules.
And the way you achieve it is by adding the requires transitive directive.
So this makes sure the dependencies are available as a transitive dependency.
Well this marks the end of this lecture.
Thank you for watching.