7

I'm trying to migrate from using Ivy to using the Aether resolver in a Grails 2.4 project.

The issue I am having is in relation to externalising the credentials. Info related to this can be found in the Grails manual here: http://grails.org/doc/latest/guide/conf.html#dependencyRepositories

There doesn't seem to be a documented way to externalise the credentials for using Maven the way you could with Ivy.

With Ivy I could place something like this into my .grails/settings.groovy file:

grails.project.ivy.authentication = {
    credentials {
        realm = "My Repo"
        host = "repo.mycustomrepo.com"
        username = "user"
        password = "password"
    }
}

To use Aether, I'm forced to place the credentials block directly in my BuildConfig.groovy like so:

repositories {
    inherits true // Whether to inherit repository definitions from plugins

    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    mavenCentral()
    mavenRepo("http://repo.mycustomrepo.com") {
      //Add authentication details to repository connection
      auth([
        username: 'user',
        password: 'password'
      ])
    }
}

Unfortunately this is really problematic for me, as within my organisation we use Artifactory which is configured to use our LDAP credentials. This is a problem because I don't want to be committing my credentials in source control.

Is there an undocumented solution for this or does Grails simply not support it?

4

1 回答 1

10

使用以下内容定义您的仓库id

 mavenRepo(id:'myrepo', url:"http://localhost:8085/artifactory/libs-release-local/") 

~/.grails/settings.groovy然后使用先前指定的定义您的凭据id

grails.project.dependency.authentication = {
  credentials {
    id = "myrepo"
    username = "foo"
    password = "bar"
  } 
}
于 2014-07-03T10:34:23.240 回答