Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure grails 2.4.0 to resolve artifacts from JFrog Artifactory with authentication?

It's a problem which every few months occurs. I do some grails upgrades and the app can't resolve my artifacts from my secured artifactory repository. This time i did an upgrade to grails 2.4.0 and yet again the problem exists. I configured my repository as described in the grails documentation (which seems very outdated) but grails can't resolve my dependencies from our repo. It doesn't authenticate correctly.

So my final questions which many people already have asked:

How to configure grails (current 2.4.0) with maven as dependency-resolver to work with a private maven respository (artifactory) with authentication correctly? What do i have to write to my BuildConfig to get it working?

This doesn't work:

if (Environment.current == Environment.PRODUCTION) {

    if (grails.project.dependency.resolver == "maven") {
        mavenRepo "http://repo.myRepoHost.com/plugins-release-local/", {
            auth([
                username: "reader",
                password: "readerPw"
            ])
        }
    }

}
like image 913
whitenexx Avatar asked Jan 21 '26 07:01

whitenexx


1 Answers

The following setup is working for me with Artifactory

grails.project.dependency.resolver = "maven"
grails.project.ivy.authentication = {
    repositories {
        mavenRepo('http://localhost:8081/artifactory/grails-remote') {
             auth([
                realm: "Artifactory Realm",
                username: 'user',
                password: 'pass'
            ])
        }
    }
}

grails.project.dependency.resolution = {
    ...
    repositories {
        inherits true
    }
    ...
}

Notice that the repository is not defined in the grails.project.dependency.resolution section.
In addition you have to make sure the "reader" user has the required permissions for the "plugins-release-local" repository.
A good way to test the repository setup is checking the Artifactory request/access log and monitoring for requests performed by Grails.

like image 57
Dror Bereznitsky Avatar answered Jan 23 '26 03:01

Dror Bereznitsky