Search code examples
mavengrailsgroovygrails-2.0rad

Grails 2.2.x - Dependency resolution using multiple custom repositories


I am trying to get dependency resolution work in Grails 2.2 using multiple customer repositories.

Currently, I am able to specify credentials section only once for a repository. What should be the configuration, if I work with multiple repositories ?

grails.project.dependency.resolution = {
    repositories { ... }
    credentials {
        realm = " "
        host = " "
        username = " "
        password = " "
    }
}

Solution

  • Unfortunately, it looks like putting credentials in settings.groovy only works for a single repo and not for multiple repos.

    So, Inside your BuildConfig.groovy, in the "repositories" block, add code like this:

    final properties = new Properties()
    properties.load(new FileInputStream(System.getProperty("user.home") + "/.grails/maven.properties"))
    final mavenUsername = properties.getProperty("user")
    final mavenPassword = properties.getProperty("password")
    
    mavenRepo ("http://repo.mycompany.com:8081/artifactory/libs-release-local") {
        auth([
            username: mavenUsername,
            password: mavenPassword
        ])
    }
    mavenRepo ("http://repo.mycompany.com:8081/artifactory/remote-repos") {
        auth([
            username: mavenUsername,
            password: mavenPassword
        ])
    } 
    

    You can refer documentation and this for more information

    Hope it helps you.