Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get insight of a dependency for the "implementation" configuration?

Tags:

gradle

Based on documentation (4.7.6 - Getting the insight into a particular dependency) we can get the insights for a particular configuration specifying the configuration itself. In the example they are using as configuration compile, which is deprecated. I tried to reproduce the same command replacing, in build.gradle, the compile configuration with the implementation configuration (as I got we are not supposed to use compile anymore). But when I run:

gradle dependencyInsight --dependency groovy --configuration implementation

Gradle is returning:

Execution failed for task ':dependencyInsight'.
Resolving configuration 'implementation' directly is not allowed

My build.gradle file is the following:

apply plugin: 'java-library'

repositories {
    jcenter()
}

dependencies{
    implementation 'org.codehaus.groovy:groovy-all:2.4.10'
}

Does it mean I cannot get the insight of a dependency if I'm using implementation or is there another way to get it?

like image 454
acejazz Avatar asked Oct 18 '17 07:10

acejazz


People also ask

What is implementation dependency?

Implementation dependencies : The references used in the relations between components are typed using concrete classes or abstract classes. Interface dependencies: The references used in the relations between components are typed using only interfaces.

How do you view dependency hierarchy in Gradle?

If you want to visualize your dependencies in a graph you can use gradle-dependency-graph-generator plugin. Generally the output of this plugin can be found in build/reports/dependency-graph directory and it contains three files (. dot|.

How do you read a Gradle dependency tree?

In Gradle dependencies are libraries required to build your code. Each of these libraries may have their own dependencies, adding transitive dependencies to your project. This structure is called the Gradle dependency tree, with its own rules on dependency conflict resolution and more.


2 Answers

I had a similar problem, asked around and got this answer:

The configuration is compileClasspath. If you have variants, there is a configuration per-variant (e.g. for the release variant, your configuration would be releaseCompileClasspath).

Examples

  1. No variants: gradle dependencyInsight --dependency groovy --configuration compileClasspath;
  2. Release variant: gradle dependencyInsight --dependency groovy --configuration releaseCompileClasspath

Note

There are a few ways to figure out the available configurations.

  1. If you add configurations.each { println it.name } to your top-level gradle file, the next time you run a task, you'll also get a list of all of your configurations.
  2. Run the dependencies task on your top-level module - this will output all dependencies for all configurations. It can be a lot of text, so you could pipe it into a text file for easier searching (gradle dependencies > dependencies.txt)
like image 70
Eric Brynsvold Avatar answered Oct 11 '22 19:10

Eric Brynsvold


To get the list of available configuration that can be used with dependencyInsight, the easy way is the following :

  1. Open gradle view in android studio View > Tool Windows > Gradle
  2. Select and run task 'Your App' > Tasks > Android > androidDependencies

Then you have a list of all dependencies for all available configuration, just pick one and run :

gradle :mymodule:dependencyInsight --dependency okhttp --configuration flavourDebugCompileClasspath

Hope it helps

like image 26
avianey Avatar answered Oct 11 '22 17:10

avianey