How to get a reference of a jar file when knowing "groupId:artifactId:version" info?

(Yong Cheng) #1

how to get a reference of a jar file from “groupId:artifactId:version” info? Because I have a method with a file parameter - analyze(File jar), and at that point I know “groupId:artifactId:version” info. I’m think there could have some API to handle this.

Thanks in advance

(Benjamin Muschko) #2

I assume you are talking about a JAR file declared as dependency in your build script? Here’s an example:

configurations {
  dependencies {
    myConf 'commons-lang:commons-lang:2.5'
  repositories {
  def myDep = configurations.myConf.files { dep -> == 'commons-lang' && == 'commons-lang' && dep.version == '2.5' }
  task printDep << {
    println myDep

(Yong Cheng) #3

Benjamin, thank you for your quick replying.

I sorry, I didn’t clear that I’m writing a Gradle plugin, I need the jar file inside my @TaskAction method.


def jarProcess() {


analyze(File jar)


Additionally, the “group:artifactId:version” may or maynot declared in build.gradle. For my purpose, it’s best to call one repository API to do this.

I’m guessing“group”, “artifactId”, “version”)

If you have any idea about this, really appreciate it

(Benjamin Muschko) #4

You can achieve similar things within a custom task. Remember that you always have a reference to the Project instance via the property “project”.