Home > Enterprise >  With gradle how to get the dependency tree of a library?
With gradle how to get the dependency tree of a library?

Time:11-09

Say I want to retrieve with graddle the dependancy tree of this artifact : com.google.firebase:firebase-firestore:24.4.0

How can I do ?

CodePudding user response:

You can't do that, An aar does not contain any dependency information by itself.

All the information of this aar is stored in pom.xml which can be found here over google maven repo.

And this will only show you what Gradle dependencies command will do, and those are the transitive dependencies meaning the direct dependencies for this aar, Which By default, Gradle resolves them automatically.

the pom.xml for com.google.firebase:firebase-firestore:24.4.0

<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-firestore</artifactId>
  <version>24.4.0</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>androidx.annotation</groupId>
      <artifactId>annotation</artifactId>
      <version>1.1.0</version>
      <scope>compile</scope>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services-base</artifactId>
      <version>18.0.1</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>
  </dependencies>
  <name>firebase-firestore</name>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
</project>

This pom.xml include com.google.android.gms which has its own pom.xml

<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.google.android.gms</groupId>
  <artifactId>play-services-basement</artifactId>
  <version>18.1.0</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>androidx.collection</groupId>
      <artifactId>collection</artifactId>
      <version>1.0.0</version>
      <scope>compile</scope>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>androidx.core</groupId>
      <artifactId>core</artifactId>
      <version>1.2.0</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>
    <dependency>
      <groupId>androidx.fragment</groupId>
      <artifactId>fragment</artifactId>
      <version>1.0.0</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>
  </dependencies>
  <name>play-services-basement</name>
  <licenses>
    <license>
      <name>Android Software Development Kit License</name>
      <url>https://developer.android.com/studio/terms.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
</project>

What I am trying to say, Is that unless you iterate the process and fetch the POM files of the dependencies yourself, with a custom task, All you can use is gradle dependencies command to check the transitive dependencies used by your project or module.

CodePudding user response:

If it is a dependency of your project you should be able to run

gradle dependencies

and see the dependency tree for your whole project (including the subtree for this artifact)

There are more details in the answer(s) to this question: Using Gradle to find dependency tree

  • Related