WEBVTT

00:00.020 --> 00:00.530
Hi everyone.

00:00.530 --> 00:01.040
Welcome back.

00:01.040 --> 00:06.290
In this lecture we are going to learn about the technique to how to transitively have the dependencies

00:06.290 --> 00:07.940
available to the other modules.

00:07.940 --> 00:12.860
So in this case to experiment that one we are going to be working on the module three.

00:12.860 --> 00:16.970
And if you take a look at the module three you will have this file already available.

00:16.970 --> 00:21.740
So what we are going to do is let's open this file and then you will have this code commented out over

00:21.740 --> 00:23.600
there okay let's uncomment this code.

00:23.600 --> 00:25.430
So what this module is going to do.

00:25.460 --> 00:28.190
This is going to be referencing the module two.

00:28.220 --> 00:32.660
So module three is going to reference to module two okay.

00:32.690 --> 00:37.760
And if you go to the build.gradle file you will notice this module two implementation available.

00:37.760 --> 00:39.710
So let's go ahead and uncomment that code.

00:39.710 --> 00:44.060
So once you're done with that what we will do we'll go ahead and refresh the Gradle project.

00:44.060 --> 00:44.570
There you go.

00:44.570 --> 00:49.400
So now with this any code that's available in module two, whatever we have defined in the export section

00:49.400 --> 00:51.590
will be visible to the module three.

00:51.590 --> 00:53.600
So in this case we have client Dtos.

00:53.630 --> 00:54.680
We have not added it.

00:54.710 --> 01:00.740
What we will do we'll do exports comm dot module two dot dtos.

01:00.740 --> 01:03.890
And then we can actually also do the service.

01:03.890 --> 01:08.000
So any classes under this package will be visible to the module three.

01:08.030 --> 01:08.210
Right.

01:08.240 --> 01:09.800
So there are no doubts in that one.

01:09.800 --> 01:16.070
So now let's say we have a specific use case where module three requires a code that's there in module

01:16.070 --> 01:16.370
one.

01:16.370 --> 01:17.990
So it needs a code.

01:17.990 --> 01:20.720
In this case it's going to be module one service.

01:20.720 --> 01:24.950
So module three requires the module one service class.

01:24.950 --> 01:26.270
That's part of the module one.

01:26.270 --> 01:32.180
But as per our dependency tree the module three is only dependent on module right.

01:32.180 --> 01:37.190
So in this case how do we get the dependency that's present in module one.

01:37.190 --> 01:42.590
But if you all can remember module two is actually referencing module one.

01:42.620 --> 01:43.160
Right.

01:43.160 --> 01:46.760
So it has the code available to its specific module.

01:46.790 --> 01:47.090
Right.

01:47.120 --> 01:50.150
Which means module two has access to all the source code.

01:50.150 --> 01:52.790
That's part of the exports in module two.

01:52.820 --> 01:58.640
So now what are the options that we have in order to make sure module three has access to the module

01:58.640 --> 01:59.270
one code.

01:59.270 --> 02:05.990
So in this particular scenario, if you go to the module tools module info file, we can actually transitively

02:05.990 --> 02:09.110
provide that dependency available to module three.

02:09.140 --> 02:12.020
The way you do it is by using the transitive directive.

02:12.050 --> 02:13.670
So in this case let's copy this one.

02:13.670 --> 02:15.080
So I'm going to put it over here.

02:15.080 --> 02:18.860
But what I'm going to do is I'm going to have transitive over here.

02:18.860 --> 02:25.700
So when you do transitive we are actually supplying the module one dependencies also to any other module

02:25.700 --> 02:27.470
that's going to use module two.

02:27.500 --> 02:30.920
So in this case our module three is using module two.

02:30.950 --> 02:31.310
Right.

02:31.310 --> 02:34.130
So in this case you will find this class available over here.

02:34.130 --> 02:37.730
So if you go and open this class and then let's uncomment this class.

02:37.730 --> 02:43.970
So with the code setup that we have which means the module two is transitively providing module one.

02:43.970 --> 02:50.480
This means we are going to be seeing the classes that is available in module one to any other module

02:50.480 --> 02:52.790
that uses module two as a dependency.

02:52.790 --> 02:56.090
So in this case, module three uses module two as a dependency.

02:56.120 --> 03:00.380
Now if you uncomment this code you just need to automatically import the classes.

03:00.380 --> 03:04.040
But I think there is one thing which we need to uncomment in the module three.

03:04.040 --> 03:06.710
So in this case we can uncomment this one.

03:06.710 --> 03:12.710
So this should take care of having this module one also available for resolving that particular file.

03:12.710 --> 03:14.900
So let's go ahead and do a quick refresh.

03:14.900 --> 03:18.530
And then if you go here you will see this import option readily available.

03:18.560 --> 03:22.850
So as soon as you import that one you have the next import that needs to be imported.

03:22.850 --> 03:24.830
And this code compiles fine.

03:24.830 --> 03:31.010
So this is how you transitively provide the dependencies from one module to another.

03:31.010 --> 03:36.590
If you take a look at the module three file, we do not have any reference of module one here, but

03:36.590 --> 03:40.970
still we were able to access the module one code in module three.

03:41.570 --> 03:46.610
So this is all about how do you transitively provide the dependencies to other modules.

03:46.640 --> 03:50.600
And the way you achieve it is by adding the requires transitive directive.

03:50.600 --> 03:55.670
So this makes sure the dependencies are available as a transitive dependency.

03:56.030 --> 03:57.440
Well this marks the end of this lecture.

03:57.440 --> 03:58.430
Thank you for watching.
