0

I am trying to get dependency resolution to work in Grails 2.2 from a custom repository which has username password.

I have tried adding the following in my BuildConfig.groovy

grails.project.dependency.resolver = "maven"
grails.project.ivy.authentication = {
    repositories {
        mavenRepo('https://maven.companyname.com/repository/repository-name') {
            auth([
                    username: 'myusername',
                    password: 'mypassword'
            ])
        }
    }
}

But I get error like

Caused by: groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.auth() is applicable for argument types: (java.util.LinkedHashMap) values: 

I tried looking at https://grails.github.io/grails2-doc/2.2.0/guide/single.html#dependencyRepositories but it does not tell me more information. It does say that I need to put the credentials in settings.groovy but is that absolutely necessary? I tried putting the credentials inside mavenRepo closure but that did not work. Any ideas?

Aseem Bansal
  • 6,722
  • 13
  • 46
  • 84
  • I don't know the answer, but have you tried switching "grails.project.ivy.authentication" to something like "grails.project.maven.authentication"? – sf_jeff Feb 21 '20 at 20:19

1 Answers1

0

Grails 2 - quite some time ago…
This way it is working here.

BuildConfig.groovy:

…
grails.project.dependency.resolver = "ivy"
grails.project.dependency.resolution = {
repositories {
    mavenRepo "https://repo.example.com/myrepo"  
}
…

~/.grails/settings.groovy:

…
grails.project.ivy.authentication = {
        credentials {
                realm = "My Realm"
                host = "repo.example.com"
                username = "user"
                password = "secret"
        }
}
…
Sascha Frinken
  • 3,134
  • 1
  • 24
  • 27