api / org.gradle.api.artifacts.dsl / RepositoryHandler

RepositoryHandler

interface RepositoryHandler : ArtifactRepositoryContainer

A RepositoryHandler manages a set of repositories, allowing repositories to be defined and queried.

Inherited Properties

DEFAULT_MAVEN_CENTRAL_REPO_NAME

static val DEFAULT_MAVEN_CENTRAL_REPO_NAME: String

DEFAULT_MAVEN_LOCAL_REPO_NAME

static val DEFAULT_MAVEN_LOCAL_REPO_NAME: String

GOOGLE_URL

static val GOOGLE_URL: String

MAVEN_CENTRAL_URL

static val MAVEN_CENTRAL_URL: String

Functions

flatDir

abstract fun flatDir(args: MutableMap<String, *>): FlatDirectoryArtifactRepository

Adds a resolver that looks into a number of directories for artifacts. The artifacts are expected to be located in the root of the specified directories. The resolver ignores any group/organization information specified in the dependency section of your build script. If you only use this kind of resolver you might specify your dependencies like ":junit:4.4" instead of "junit:junit:4.4". The following parameter are accepted as keys for the map: Key Description of Associated Value name (optional) The name of the repository. The default is a Hash value of the rootdir paths. The name is used in the console output, to point to information related to a particular repository. A name must be unique amongst a repository group. dirs Specifies a list of rootDirs where to look for dependencies. These are evaluated as per org.gradle.api.Project#files(Object...)

Examples:

 repositories { flatDir name: 'libs', dirs: "$projectDir/libs" flatDir dirs: ["$projectDir/libs1", "$projectDir/libs2"] } 

abstract fun flatDir(configureClosure: Closure<Any>): FlatDirectoryArtifactRepository
abstract fun flatDir(action: Action<in FlatDirectoryArtifactRepository>): FlatDirectoryArtifactRepository

Adds an configures a repository which will look for dependencies in a number of local directories.

google

abstract fun google(): MavenArtifactRepository

Adds a repository which looks in Google's Maven repository for dependencies.

The URL used to access this repository is "https://dl.google.com/dl/android/maven2/".

Examples:

 repositories { google() } 

gradlePluginPortal

abstract fun gradlePluginPortal(): ArtifactRepository

Adds a repository which looks in Gradle Central Plugin Repository for dependencies.

ivy

abstract fun ivy(closure: Closure<Any>): IvyArtifactRepository

Adds and configures an Ivy repository. Newly created instance of IvyArtifactRepository is passed as an argument to the closure.

abstract fun ivy(action: Action<in IvyArtifactRepository>): IvyArtifactRepository

Adds and configures an Ivy repository.

jcenter

abstract fun jcenter(action: Action<in MavenArtifactRepository>): MavenArtifactRepository

Adds a repository which looks in Bintray's JCenter repository for dependencies.

The URL used to access this repository is "https://jcenter.bintray.com/". The behavior of this repository is otherwise the same as those added by #maven(org.gradle.api.Action).

Examples:

 repositories { jcenter { artifactUrls = ["http://www.mycompany.com/artifacts1", "http://www.mycompany.com/artifacts2"] } jcenter { name = "nonDefaultName" artifactUrls = ["http://www.mycompany.com/artifacts1"] } } 

abstract fun jcenter(): MavenArtifactRepository

Adds a repository which looks in Bintray's JCenter repository for dependencies.

The URL used to access this repository is "https://jcenter.bintray.com/". The behavior of this repository is otherwise the same as those added by #maven(org.gradle.api.Action).

Examples:

 repositories { jcenter() } 

maven

abstract fun maven(closure: Closure<Any>): MavenArtifactRepository

Adds and configures a Maven repository. Newly created instance of MavenArtifactRepository is passed as an argument to the closure.

abstract fun maven(action: Action<in MavenArtifactRepository>): MavenArtifactRepository

Adds and configures a Maven repository.

mavenCentral

abstract fun mavenCentral(args: MutableMap<String, *>): MavenArtifactRepository

Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#MAVEN_CENTRAL_URL}.

The following parameter are accepted as keys for the map:

Key Description of Associated Value name (optional) The name of the repository. The default is {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_CENTRAL_REPO_NAME} is used as the name. A name must be unique amongst a repository group. artifactUrls A single jar repository or a collection of jar repositories containing additional artifacts not found in the Maven central repository. But be aware that the POM must exist in Maven central. The provided values are evaluated as per org.gradle.api.Project#uri(Object).

Examples:

 repositories { mavenCentral artifactUrls: ["http://www.mycompany.com/artifacts1", "http://www.mycompany.com/artifacts2"] mavenCentral name: "nonDefaultName", artifactUrls: ["http://www.mycompany.com/artifacts1"] } 

abstract fun mavenCentral(): MavenArtifactRepository

Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#MAVEN_CENTRAL_URL}. The name of the repository is {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_CENTRAL_REPO_NAME}.

Examples:

 repositories { mavenCentral() } 

mavenLocal

abstract fun mavenLocal(): MavenArtifactRepository

Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_LOCAL_REPO_NAME}.

Examples:

 repositories { mavenLocal() } 

The location for the repository is determined as follows (in order of precedence):

  1. The value of system property 'maven.repo.local' if set;
  2. The value of element <localRepository> of ~/.m2/settings.xml if this file exists and element is set;
  3. The value of element <localRepository> of $M2_HOME/conf/settings.xml (where $M2_HOME is the value of the environment variable with that name) if this file exists and element is set;
  4. The path ~/.m2/repository.

Inherited Functions

add

abstract fun add(element: ArtifactRepository): Boolean

Adds a repository to this container, at the end of the repository sequence.

addFirst

abstract fun addFirst(repository: ArtifactRepository): Unit

Adds a repository to this container, at the start of the repository sequence.

addLast

abstract fun addLast(repository: ArtifactRepository): Unit

Adds a repository to this container, at the end of the repository sequence.

getAt

abstract fun getAt(name: String): ArtifactRepository

{@inheritDoc}

getByName

abstract fun getByName(name: String): ArtifactRepository
abstract fun getByName(name: String, configureClosure: Closure<Any>): ArtifactRepository
abstract fun getByName(name: String, configureAction: Action<in ArtifactRepository>): ArtifactRepository

{@inheritDoc}

Extension Functions

gradleScriptKotlin

fun RepositoryHandler.gradleScriptKotlin(): ArtifactRepository

Adds the remote repository containing the Kotlin libraries embedded in gradle-kotlin-dsl.

ivy

fun RepositoryHandler.ivy(url: Any): IvyArtifactRepository
fun RepositoryHandler.ivy(url: Any, action: IvyArtifactRepository.() -> Unit): IvyArtifactRepository

Adds and configures an Ivy repository.

maven

fun RepositoryHandler.maven(url: Any): MavenArtifactRepository
fun RepositoryHandler.maven(url: Any, action: MavenArtifactRepository.() -> Unit): MavenArtifactRepository

Adds and configures a Maven repository.