How to add dependencies from Artifactory to my Gradle project?


(khouloud) #1

Hello, I am dealing with Gradle project and Artifactory. I’m trying to add some dependencies to my gradle project by adding :

repositories {
maven {
url 'http://localhost:8081/artifactory/libs-release-local/com/fasterxml/jackson/core/jackson-annotations/'
credentials {
username = "${artifactory_user}"
password = “${artifactory_password}”
}}

}

dependencies {
compile group: ‘com/fasterxml/jackson/core’, name: ‘jackson-annotations’, version: ‘2.6.3’, ext: ‘pom’
}

However, there is no jar added to my project.


(Carlo Luib-Finetti) #2

I think the used URL is invalid; it should only be


(khouloud) #3

even if I use this URL: ‘http://localhost:8081/artifactory/libs-release-local’ , no jar is added to my project.


(Carlo Luib-Finetti) #4

on command line, do you see any download failures?

this works for us:

we defined url and credentials in ‘gradle.properties’ and have this in ‘build.gradle’:

repositories {
      maven {
         url artifactoryUrl
            credentials {
                username artifactoryUser
                password artifactoryPassword
            }
     }
   }

(khouloud) #5

Thanks @carlo_lf for your help,
it’s true, there is no download failures, I checked ‘.gradle\caches\modules-2\files-2.1’ and I found all the downloaded jar, Since I’m a new be with gradle didn’t know about the gradle cache …
But I still don’t understand why the downloaded jar are not visible in my eclipse project under ‘Project and External Dependecies’


(Carlo Luib-Finetti) #6

Do have Buildship as Eclipse plugin? Then select the project and do ‘Gradle refresh project’. This will add the jar(s) to the Eclipse classpath.


(khouloud) #7

Actually, I’m working with Eclipse Oxygen, but I don’t have Eclipse Buildship plugin… I will try to add it and see the result.


(Carlo Luib-Finetti) #8

yes, you should if your projects are Gradle and Eclipse projects.