# RepositoryHandler

API Documentation: | `RepositoryHandler`

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

### Properties

No properties

### Script blocks

No script blocks

### Methods

Method | Description
`flatDir(configureClosure)` | Adds an configures a repository which will look for dependencies in a number of local directories.
`flatDir(args)` | 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:
`flatDir(action)` | Adds an configures a repository which will look for dependencies in a number of local directories.
`ivy(closure)` | Adds and configures an Ivy repository.
`ivy(action)` | Adds and configures an Ivy repository.
`jcenter()` | Adds a repository which looks in Bintray's JCenter repository for dependencies.
`jcenter(action)` | Adds a repository which looks in Bintray's JCenter repository for dependencies.
`maven(closure)` | Adds and configures a Maven repository.
`maven(action)` | Adds and configures a Maven repository.
`mavenCentral()` | Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is `http://repo1.maven.org/maven2/`. The name of the repository is `MavenRepo`.
`mavenCentral(args)` | Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is `http://repo1.maven.org/maven2/`. The behavior of this resolver is otherwise the same as the ones added by `RepositoryHandler.mavenRepo()`. The following parameter are accepted as keys for the map:
`mavenLocal()` | Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is `MavenLocal`.
`mavenRepo(args)` | Deprecated Adds a repository which is Maven compatible. The compatibility is in regard to layout, snapshot handling and dealing with the pom.xml. This repository can't be used for publishing in a Maven compatible way. For publishing to a Maven repository, have a look at `MavenRepositoryHandlerConvention.mavenDeployer()` or `MavenRepositoryHandlerConvention.mavenInstaller()`. By default the repository accepts to resolve artifacts without a POM. The repository always looks first for the POM in the root repository. It then looks for the artifact in the root repository. Sometimes the artifact lives in a different repository than the POM. In such a case you can specify further locations to look for an artifact. But be aware that the POM is only looked up in the root repository. The following parameter are accepted as keys for the map:
`mavenRepo(args, configClosure)` | Deprecated Adds a repository which is Maven compatible.

#### Methods added by the `maven` plugin

Method | Description
`mavenDeployer()` | Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.
`mavenDeployer(configureClosure)` | Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.
`mavenDeployer(args)` | Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies. The following parameter are accepted as keys for the map:
`mavenDeployer(args, configureClosure)` | Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.
`mavenInstaller()` | Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.
`mavenInstaller(configureClosure)` | Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.
`mavenInstaller(args)` | Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies. The following parameter are accepted as keys for the map:
`mavenInstaller(args, configureClosure)` | Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.

### Method details

#### `FlatDirectoryArtifactRepository` `flatDir`(`Closure` configureClosure)

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

#### `FlatDirectoryArtifactRepository` `flatDir`(``Map`<`String`, ?>` args)

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 `Project.files()`

Examples:

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

#### `FlatDirectoryArtifactRepository` `flatDir`(``Action`<? super `FlatDirectoryArtifactRepository`>` action)

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

#### `IvyArtifactRepository` `ivy`(`Closure` closure)

Adds and configures an Ivy repository.

#### `IvyArtifactRepository` `ivy`(``Action`<? super `IvyArtifactRepository`>` action)

Adds and configures an Ivy repository.

#### `MavenArtifactRepository` `jcenter`()

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

The URL used to access this repository is "http://jcenter.bintray.com/". The behavior of this resolver is otherwise the same as the ones added by `RepositoryHandler.mavenCentral()`.

Examples:

    repositories {
        jcenter()
    }

#### `MavenArtifactRepository` `jcenter`(``Action`<? super `MavenArtifactRepository`>` action)

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

The URL used to access this repository is "http://jcenter.bintray.com/". The behavior of this resolver is otherwise the same as the ones added by `RepositoryHandler.maven()`.

Examples:

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

#### `MavenArtifactRepository` `maven`(`Closure` closure)

Adds and configures a Maven repository.

#### `MavenArtifactRepository` `maven`(``Action`<? super `MavenArtifactRepository`>` action)

Adds and configures a Maven repository.

#### `MavenArtifactRepository` `mavenCentral`()

Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is `http://repo1.maven.org/maven2/`. The name of the repository is `MavenRepo`.

Examples:

    repositories {
        mavenCentral()
    }

#### `MavenArtifactRepository` `mavenCentral`(``Map`<`String`, ?>` args)

Adds a repository which looks in the Maven central repository for dependencies. The URL used to access this repository is `http://repo1.maven.org/maven2/`. The behavior of this resolver is otherwise the same as the ones added by `RepositoryHandler.mavenRepo()`. 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 `MavenRepo` 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 `Project.uri()`.

Examples:

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

#### `MavenArtifactRepository` `mavenLocal`()

Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is `MavenLocal`.

Examples:

    repositories {
        mavenLocal()
    }

#### `org.apache.ivy.plugins.resolver.DependencyResolver` `mavenRepo`(``Map`<`String`, ?>` args)

Note: This method is deprecated and will be removed in the next major version of Gradle.

Adds a repository which is Maven compatible. The compatibility is in regard to layout, snapshot handling and dealing with the pom.xml. This repository can't be used for publishing in a Maven compatible way. For publishing to a Maven repository, have a look at `MavenRepositoryHandlerConvention.mavenDeployer()` or `MavenRepositoryHandlerConvention.mavenInstaller()`. By default the repository accepts to resolve artifacts without a POM. The repository always looks first for the POM in the root repository. It then looks for the artifact in the root repository. Sometimes the artifact lives in a different repository than the POM. In such a case you can specify further locations to look for an artifact. But be aware that the POM is only looked up in the root repository. 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 the URL of the root repo. 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.
`url` | The root repository where POM files and artifacts are located. The provided values are evaluated as per `Project.uri()`.
`artifactUrls` | A single jar repository or a collection of jar repositories containing additional artifacts not found in the root repository. Sometimes the artifact lives in a different repository than the POM. In such a case you can specify further locations to look for an artifact. But be aware that the POM is only looked up in the root repository. The provided values are evaluated as per `Project.uri()`.

Examples:

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

For Ivy related reasons, Maven Snapshot dependencies are only properly resolved if no additional jar locations are specified. This is unfortunate and we hope to improve this in a future release.

#### `org.apache.ivy.plugins.resolver.DependencyResolver` `mavenRepo`(``Map`<`String`, ?>` args, `Closure` configClosure)

Note: This method is deprecated and will be removed in the next major version of Gradle.

Adds a repository which is Maven compatible.

#### `GroovyMavenDeployer` `mavenDeployer`()

Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.

#### `GroovyMavenDeployer` `mavenDeployer`(`Closure` configureClosure)

Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.

#### `GroovyMavenDeployer` `mavenDeployer`(``Map`<`String`, ?>` args)

Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies. 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 mavenDeployer-{SOME_ID}. 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.

#### `GroovyMavenDeployer` `mavenDeployer`(``Map`<`String`, ?>` args, `Closure` configureClosure)

Adds a repository for publishing to a Maven repository. This repository can not be used for resolving dependencies.

#### `MavenResolver` `mavenInstaller`()

Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.

#### `MavenResolver` `mavenInstaller`(`Closure` configureClosure)

Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.

#### `MavenResolver` `mavenInstaller`(``Map`<`String`, ?>` args)

Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies. 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 mavenInstaller-{SOME_ID}. 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.

#### `MavenResolver` `mavenInstaller`(``Map`<`String`, ?>` args, `Closure` configureClosure)

Adds a repository for installing to a local Maven cache. This repository can not be used for resolving dependencies.