I've been reading the Gradle docs to learn more about how Gradle manage the dependencies in an Android project.
Finally I understand The Java Library Plugin decide how to build and run a project using the following configurations.
- api
- implementation
- compileOnly
- runtimeOnly
However I'm trying to check the differences of those configurations using android libraries as retrofit, glide or okHttp and I'm not able to find one. For example, let's say I want to try OkHttp.
Using API
api "com.squareup.okhttp3:okhttp:4.6.0"
Using implementation
implementation "com.squareup.okhttp3:okhttp:4.6.0"
I don't see any difference in Project -> External Libraries -> com.squareup.okhttp3
or using ./gradlew app:androidDependencies
I'm not sure if this configurations are only useful in a multimodule project, where its easier check the differences (at least api vs implementation).
If I go deeper in the OkHttp pom.xml
I don't know which configuration is used: api
, implementation
, compileOnly
, runtimeOnly
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>parent</artifactId>
<version>3.14.7</version>
</parent>
<artifactId>okhttp</artifactId>
<name>OkHttp</name>
<dependencies>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
</dependency>
<dependency>
<groupId>org.conscrypt</groupId>
<artifactId>conscrypt-openjdk-uber</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>android-all</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
<version>1.17</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<excludePackageNames>okhttp3.internal:okhttp3.internal.*</excludePackageNames>
<links>
<link>http://square.github.io/okio/</link>
</links>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>okhttp3</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Questions
- How can check the difference between configurations using a remote library instead of submodules.
- How
pom.xml
knows about its configurations dependencies? - Maybe OkHttp is not the best example, is there any better to explain this questions?
Could someone give me a hand? I can provide more details if needed. Or I can pay for support haha.