Lets say 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 for me to get the absolute file path location of the 2 .jar files resulting from the above dependency, as a List object?
The following piece of code will do the job:
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 }
}
Don't know what's your goal but in general that's the way to go.
Yes you can get physical path location from Configurations object. Reference: http://discuss.gradle.org/t/what-is-the-best-way-to-resolve-the-physical-location-of-a-declared-dependency/6999
This is how I did it, more explicitly:
project.buildscript.configurations.classpath.each {
String jarName = it.getName();
print jarName + ":"
}
Here is my build script URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With