Gradle : Repository Configuration


In Gradle, build.gradle file specifies repositories to search dependencies of projects. Gradle support repositories configuration for Ivy and Maven.

Maven Repository

You can configure maven repositories in Gradle in multiple ways:

  1. Maven Central Repository
    repositories {
        mavenCentral()
    }
  2. Maven Repository by  Target URL
    repositories {
        maven {url "http://repo.myoffice.com/maven2"}
    }
  3. Maven Repository for Other Target       For example Bintray as Maven repository
    repositories {
        maven ("http://jcenter.bintray.com/")
    }

Ivy Repository

You can also set Ivy repository as below.

repositories {
    ivy { url "http://repo.mycompany.com/repo"}
}

Dependencies from Multiple Repositories

You can add multiple dependencies at once.

repositories {
   maven ("https://repository-engine.forge.cloudbees.com/snapshot/")
   jcenter {
      url "http://jcenter.bintray.com/"
   }
}

Now you have learned about the ways to configure Gradle repositories in build.gradle file to search dependencies. In case if you want to use dependencies from your local file system you can figure that also in the dependencies section. Check Gradle: Dependencies Configuration to know more about it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s