ScArcher2
ScArcher2

Reputation: 87187

How do you configure grails to resolve dependencies from a password protected repository?

I have a password protected internal maven repository I'd like to use to resolve dependencies in grails.

Does anyone know how to configure grails to use authentication when accessing a repository?

I'm running grails 1.2.1.

Upvotes: 4

Views: 1895

Answers (2)

aruizca
aruizca

Reputation: 1919

Just making Brandon answer a bit more specific for the Nexus and Artifactory Maven repositories, as the realm attribute is key for this to work.

If you are using Nexus the credentials block look like this:

credentials {
    realm = "Sonatype Nexus Repository Manager"
    host = "hostname"
    username = "username"
    password = "password"
}

, but if you are using Artifactory, it should look like this:

credentials {
    realm = "Artifactory Realm"
    host = "hostname"
    username = "username"
    password = "password"
}

You need to add this block to your BuildConfig.groovy file, but if your code is going to be open sourced or you want this setting for all your projects, you can add the block inside your ~/.grails/settings.groovylike this:

grails.project.ivy.authentication = {
    credentials {
        realm = "your realm"
        host = "hostname"
        username = "username"
        password = "password"
    }
}

Cheers,

Angel.

Upvotes: 1

Brandon
Brandon

Reputation: 2920

You can look in the docs: 3.7.2) Dependency Repositories -> Authentication

From the Docs:

If your repository requires some form of authentication you can specify as such using a credentials block:

credentials {
  realm = ".."
  host = "localhost"
  username = "myuser"
  password = "mypass"
}

Upvotes: 4

Related Questions