Get a path to dependencie's jar file


(bogaty_f1) #1

Is it possible to get a path to jarFile which presents a jar file writen in dependencies block?

Sample instance:

apply plugin: 'java'
  repositories.mavenCentral()
dependencies {
    testCompile 'org.testng:testng:6.8.1'
}
  task myTask(){
   // ...
   getDependenciesPath()
   /// ...
}
  String getDependenciesPath(){
   // code that gets the path to already compiled TESTNG library...
}

Basicaly that is because I need to execute a task, which should contain a path to library, which it depends On


(bogaty_f1) #2

found solution:

configurations.compile.each {
        println it
}

this will show all the jars pathes for this configuration


(uklance) #3

ResolvedArtifact artifact = configurations.testCompile.resolvedConfiguration.resolvedArtifacts.find { it.moduleVersion.id.name == “testng” } def id = artifact.moduleVersion.id println “$artifact.file, $id.group, $id.name, $id.version”