5.7.2 Dependency Repositories - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 2.4.4
5.7.2 Dependency Repositories
Remote Repositories
Initially your BuildConfig.groovy does not use any remote public Maven repositories. There is a defaultgrailsHome() repository that will locate the JAR files Grails needs from your Grails installation. To use a public repository, specify it in the repositories block:repositories {
mavenCentral()
}repositories {
mavenRepo "http://repository.codehaus.org"
}repositories {
mavenRepo name: "Codehaus", root: "http://repository.codehaus.org"
}Offline Mode
There are times when it is not desirable to connect to any remote repositories (whilst working on the train for example!). In this case you can use theoffline flag to execute Grails commands and Grails will not connect to any remote repositories:grails --offline run-app
Note that this command will fail if you do not have the necessary dependencies in your local Maven cacheYou can also globally configure offline mode by setting
grails.offline.mode to true in ~/.grails/settings.groovy or in your project's BuildConfig.groovy file:grails.offline.mode=true~/.m2/repository) as a repository:repositories {
mavenLocal()
}Authentication with Aether
To authenticate with Aether you can either define the credentials on the repository definition:mavenRepo(url:"http://localhost:8082/myrepo") { auth username: "foo", password: "bar" }
id on the repository:mavenRepo(id:'myrepo', url:"http://localhost:8082/myrepo")USER_HOME/.grails/settings.groovy:grails.project.dependency.authentication = {
credentials {
id = "myrepo"
username = "admin"
password = "password"
}
}Authentication with Ivy
If your repository requires authentication you can configure this using acredentials block:credentials {
realm = ".."
host = "localhost"
username = "myuser"
password = "mypass"
}USER_HOME/.grails/settings.groovy file using the grails.project.ivy.authentication setting:grails.project.ivy.authentication = {
credentials {
realm = ".."
host = "localhost"
username = "myuser"
password = "mypass"
}
}
