1

Let's assume I have the following libraries defined in a gradle.build file:

dependencies {
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.squareup.okhttp:okhttp:2.6.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.facebook.android:facebook-android-sdk:4.8.2'
    //...
}

Now, some of these libraries are dependent on other libraries. Given the library name, is there a way to know the list of libraries the given library depend on? I am only interested on the names and versions of those libraries for a webapp project. I tries reading Bintray API but couldn't find the way to do it there.


EDIT:

I'm not looking for the dependency tree of my app (i.e. the gradle dependencies command). I'm just interested in building a web app, where the user provides any project (hosted in Maven on JCenter) and the web app will return the dependency tree.

iTurki
  • 16,292
  • 20
  • 87
  • 132
  • Possible duplicate of [What is the Gradle artifact dependency graph command?](http://stackoverflow.com/questions/12288133/what-is-the-gradle-artifact-dependency-graph-command) – JBaruch Nov 30 '15 at 15:10
  • Thanks @JBaruch , but I'm not looking for my app's dependencies. I'm interested in showing the dependency tree of a certain project (facebook-android-sdk for example) in a web app. – iTurki Dec 01 '15 at 10:04

1 Answers1

1

Just take the pom file of the library and run mvn dependency:tree on it with outputType parameter set to graphml.

JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • Given the library/project name, how can I retrieve the pom file programmatically? The pom file contains all the info I need, but my problem is how to get it. Maven and JCenter APIs didn't help me. – iTurki Dec 01 '15 at 16:51
  • that's the same file name with `.pom` as an extension. – JBaruch Dec 01 '15 at 22:59
  • Yes, but how to know the file's url? For example, if I have `com.facebook.android:facebook-android-sdk:4.8.2` as an input, how to get its [pom file](https://repo1.maven.org/maven2/com/facebook/android/facebook-android-sdk/4.8.2/facebook-android-sdk-4.8.2.pom)? The input could be any library the end user provide. Facebook Android SDK is just an example. – iTurki Dec 02 '15 at 21:33
  • 1
    They are in Maven layout: replace `.` with `/` in group id, then the artifactId, then the version, and for the filename it's the artifactId dash the version, and `pom` as extension. – JBaruch Dec 04 '15 at 00:52
  • Fantastic! I tested this with a couple of libraries and it seems consistent. My only concern now is with `https://(repo1).maven.org/(maven2)`. I get the feeling that there is `repo2`, `repo3`, `maven1` and `maven3`. – iTurki Dec 04 '15 at 15:03