How to externalize Maven credentials in Grails 2.4

I am trying to move from using Ivy to using an ether analyzer in a Grails 2.4 project.

The problem I am facing is related to externalization of credentials. Information related to this can be found in the Grails manual: http://grails.org/doc/latest/guide/conf.html#dependencyRepositories

There doesn't seem to be a documented way of externalizing credentials to use Maven, as you could with Ivy.

With Ivy, I can put something like this in 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 have to place the credential block directly in my BuildConfig.groovy like this:

 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, because in my organization we use Artifactory, which is configured to use our LDAP credentials. This is a problem because I do not want to fulfill my credentials in source control.

Is there an undocumented solution for this, or is Grails just not supporting it?

+7
maven grails aether
source share
1 answer

Define your repo with id :

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

Then define your credentials in ~/.grails/settings.groovy using the previously specified id :

 grails.project.dependency.authentication = { credentials { id = "myrepo" username = "foo" password = "bar" } } 
+9
source share

All Articles