Reputation: 73
I have a project layout as follows:
+-- app
| +-- builds
| +-- libs
| +-- src
+-- my-lib
| +-- builds
| +-- libs
| | +-- lib1.jar
I have already added my-lib as implementation project (':my-lib')
in app
module, how do I use lib1
classes inside app
module?
Upvotes: 1
Views: 71
Reputation: 8549
In my-lib1
library dependency section use api
instead of implementation
to include the lib1
library like below.
dependecies {
api files('libs/lib1.jar')
... some other libraries ...
}
tl;dr
Difference between api
and implementation
is explained like below in gradle docs website.
The
api
configuration should be used to declare dependencies which are exported by the library API, whereas theimplementation
configuration should be used to declare dependencies which are internal to the component.
Impacts on using api
It'll increase the build time if you are doing any changes in lib1
. Because it need to rebuild your my-lib
and app
. In your case it won't happen. Check this reference article for more info.
Upvotes: 1