7

if we take a look at gradle build tools we'll notice that compile configuration dependency is deprecated in favor of api and implementation. See here

so i had question on dependency visiblity using api. Imagine we have the following set in a module called app:

dependencies {
    api 'commons-httpclient:commons-httpclient:3.1'
    implementation 'org.apache.commons:commons-lang3:3.5'
}

So from what i gather the org.apache.commons:commons-lang3:3.5 will only be available in the module itself. but the commons-httpclient:commons-httpclient:3.1 dependency will abe available outside of the module, what does that actually mean ?does that mean if i made my app module into a library that the dependency will be available to whoever uses the library, (wasn't it always like that anyway ?

this is what the android docs have to say about api configuration:

api compile The dependency is available to the module at compile time, and it's also available to the consumer of the module at compile time and runtime. This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library modules. App modules should use implementation, unless you want to expose its API to a separate test module. compileOnly provided

j2emanue
  • 51,417
  • 46
  • 239
  • 380
  • 2
    `api` = `compile` so it will be visible to the app module (i.e. available at compile time). `implementation` will *not* be visible to your app module. Both will be included in the .apk (i.e. available at runtime). – Eugen Pechanec May 28 '17 at 22:17
  • 2
    i thought implementation = compile – j2emanue May 29 '17 at 20:14
  • 1
    Think API = public, implementation = hidden. *I want this dependency be part of my public API* vs *my implementation detail.* – Eugen Pechanec May 29 '17 at 22:21
  • I've created an answer on this topic [here](https://stackoverflow.com/a/44419574/2910520), maybe can help you :) – MatPag Jun 07 '17 at 18:07
  • https://docs.gradle.org/current/userguide/img/java-library-ignore-deprecated-test.png – Martin Zeitler Dec 17 '17 at 04:16

0 Answers0