开发者

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.

开发者_如何学JAVA

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

I'm running grails 1.2.1.


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"
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜