1

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 ?

zeus
  • 12,173
  • 9
  • 63
  • 184
  • Does this answer your question? [Using Gradle to find dependency tree](https://stackoverflow.com/questions/21645071/using-gradle-to-find-dependency-tree) – Nick Nov 08 '22 at 22:24
  • @Nick no not really, me I don't even have any project, I just want to dependancy tree of com.google.firebase:firebase-firestore:24.4.0 and i don't know how to do. – zeus Nov 09 '22 at 05:25
  • I already wrote to you that you can use the website https://stackoverflow.com/a/74235627/6066470 – Nick Nov 09 '22 at 07:09

2 Answers2

3

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.

UPDATE:

You can easily start a new gradle project by following these simple steps.

  1. mkdir gradleExp
  2. cd gradleExp
  3. gradle init # 1.basic 1.groovy random name
  4. update the empty build.gradle with the following
plugins {
    id 'java'
}
repositories {
    google()
    mavenCentral()
}

dependencies {
    implementation "com.google.firebase:firebase-firestore:24.4.0"
}
  1. gradle dependencies # to list all
  2. gradle dependencies --configuration compileClasspath # reduce output to show only Compile classpath for source set 'main'

NOTE: missing either google() or mavenCentral() will show some failure in the result shown.

George
  • 2,292
  • 2
  • 10
  • 21
  • Is it possible to createan empty project with just my dependency to run on it gradle dependencies? if yes how to do ? – zeus Nov 09 '22 at 12:25
  • 1
    yes, And i believe its pretty simple, I will update my answer now. – George Nov 09 '22 at 12:36
  • I have a strange problem with your solution, I open a new SO with this problem here: https://stackoverflow.com/questions/74482724/gradle-dependencies-failed-for-an-unknown-reason – zeus Nov 17 '22 at 22:17
  • 1
    I have added an answer to your question, It should work fine now. – George Nov 21 '22 at 17:22
0

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

Ben Borchard
  • 631
  • 3
  • 9