What's the difference between implementation, api and compile in Gradle?
Gradle
What’s the difference between implementation, api and compile (compileOnly, runtimeOnly, testImplementation, testCompileOnly, testRuntimeOnly) in Gradle?
Name | Role | Consumable? | Resolveable? | Description |
---|---|---|---|---|
api | Declaring API dependencies | no | no | This is where you should declare dependencies which are transitively exported to consumers, for compile. |
implementation | Declaring implementation dependencies | no | no | This is where you should declare dependencies which are purely internal and not meant to be exposed to consumers. |
compileOnly | Declaring compileOnly dependencies | yes | yes | This is where you should declare dependencies which are only required at compile time, but should not leak into the runtime. This typically includes dependencies which are shaded when found at runtime. |
runtimeOnly | Declaring runtime dependencies | no | no | This is where you should declare dependencies which are only required at runtime, and not at compile time. |
testImplementation | Test dependencies | no | no | This is where you should declare dependencies which are used to compile tests. |
testCompileOnly | Declaring test compile only dependencies | yes | yes | This is where you should declare dependencies which are only required at test compile time, but should not leak into the runtime. This typically includes dependencies which are shaded when found at runtime. |
testRuntimeOnly | Declaring test runtime dependencies | no | no | This is where you should declare dependencies which are only required at test runtime, and not at test compile time. |
References
This post is licensed under CC BY 4.0 by the author.