Search artifactory based on group id and download the artifacts

(Abhishek Poddar) #1

I’ve written a task to download artifacts from artiactory.

task downloadZip(type: Copy) {
   from configurations.build1
   into 'D:/EclipseWorkspace/GradleTest/target'

build1 is the dependency hardcoded with (group, name , version). Instead I want to do a look up in artifactory using a regular expression and then download all matching artefacts. I’ve below algorithm in mind

1.Query artifactory -gradle equivalent of a package searh GAVC in maven) - is it possible ?
2.create dynamic dependencies based on search Query result. - Still looking into examples.Highly appreciate if you can point me to right direction.
3. Modify the task to run a loop of copy for each artifact.

(Benjamin Muschko) #2

I’d use the RESTful API exposed by Artifactory to determine the GAVs that you can then download with Gradle.

(Abhishek Poddar) #3

Thanks REST API helped. I’ve parsed the http response to extra group, name, version needed to create dependency. I’m try to add dependency as below:

def groupId = //parse http response
def artiId = //parse http response
def artiVersion = //parse http response
def myNotation = groupId+":"+artiId+":"+artiVersion+"@‘zip’"
project.dependencies.add(myConfName, myNotation)

I get below exception

Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configur
ation failure takes precedence.
org.gradle.api.ProjectConfigurationException: A problem occurred configuring roo
t project ‘GradleTest’.

A problem occurred evaluating root project ‘GradleTest’.
java.lang.NullPointerException (no error message)