How can I list all dependencies jar/aar filepath on local machine?

I want to list all dependencies jar/aar filepath to analyze these jar/aar files.But the task ‘dependencies’ only list the dependencies notation as a tree. I wanna jar/aar file paths,how can i reach it?

val foo by tasks.registering {
    doLast {
        configurations
            .filter { it.isCanBeResolved }
            .flatMap { it.files }
            .sorted()
            .distinct()
            .forEach(::println)
    }
}

Thank you for your reply.
I found it works well for JVM build.But for my Android app project which has some build flavors and build types, it has somethong wrong .
The operation of

.flatMap { it.files }

confuses Gradle because he says:

Could not resolve all files for configuration ':app:cnPadDebugAndroidTestCompileClasspath'.
   > The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.ProductFlavor:device' with value 'pad', attribute 'com.android.build.api.attributes.ProductFlavor:region' with value 'cn', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.2.1', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :app:
       - Configuration ':app:cnPadDebugTestFixturesApiElements' variant android-lint-local-aar declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.2.1', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.ProductFlavor:device' with value 'pad', attribute 'com.android.build.api.attributes.ProductFlavor:region' with value 'cn':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-lint-local-aar' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'cnPadDebug' but the consumer didn't ask for it
               - Provides attribute 'device' with value 'pad' but the consumer didn't ask for it
               - Doesn't say anything about its target Java environment (preferred optimized for Android)
               - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
               - Provides attribute 'region' with value 'cn' but the consumer didn't ask for it

I don’t quite understand what Gradle says,and don’t know hot to fix it :flushed:.This error message is one of configurations and all meesages look similar,so I just post one here.
Looking forward to your reply.Thanks.

The snippet I have you is fine
The .files is the point where the resolvable configurations are actually resolved.
And it seems you misconfigured your build, so that not all configurations can be resolved.

You didn’t even post one complete error, but only the beginning. It tells you that you have declared a dependency that cannot be resolved as there are multiple matching target variants and you just posted the first one.

Anyway that does not really have anything to do with the topic of this thread and I’m not developing for Android. I suggest you open a new thread with your new problem.

Ok thankyou for your suggestion :grinning: