How to get the location of the path to the .jar dependency file?

Suppose I have this dependency defined in my build.gradle:

dependencies {
    classpath "org.codehaus.groovy:groovy-all:2.4.0"
    classpath "com.opencsv:opencsv:3.1"
}

Is there a way to get the absolute location of the file path from 2.jar files resulting from the above dependency as a List object?

+4
source share
3 answers

The following code fragment will complete the task:

apply plugin: 'java'

repositories {
   mavenCentral()
}

configurations {
   lol
}

dependencies {
    lol "org.codehaus.groovy:groovy-all:2.4.0"
    lol "com.opencsv:opencsv:3.1"
}

task printLocations << {
   configurations.lol.files.each { println it }
}

I don’t know what your goal is, but overall, what a way.

+13
source

Yes, you can get the physical location of the path from the Configurations object. Link: http://discuss.gradle.org/t/what-is-the-best-way-to-resolve-the-physical-location-of-a-declared-dependency/6999

+1
source

, :

project.buildscript.configurations.classpath.each {
    String jarName = it.getName();
    print jarName + ":"
}

script URL.

+1

All Articles