Gradle Repository

Cloudsmith provides public & private repositories for Gradle


Gradle is an open-source build-automation tool that harnesses the power of Maven via a Groovy-based domain-specific language making it easier to define projects and their dependencies.

For more information on Gradle, please see:

  • Gradle: The official website for Gradle
  • Gradle Docs: The official documentation for Gradle
Contextual Documentation

The examples in this document are generic. Cloudsmith provides contextual setup instructions within each repository, complete with copy n' paste snippets (with your namespace/repo pre-configured).

In the following examples:




Your Cloudsmith account name or organisation name (namespace)


Your Cloudsmith Repository name (also called "slug")


Your Cloudsmith Entitlement Token (see Entitlements for more details)


Your Cloudsmith username


Your Cloudsmith password


Your Cloudsmith API Key


The version number of your package


A unique Maven identifier for your project across all projects i.e "com.companyname.project"


The name of the jar without version i.e "project"


These examples use the Groovy-based syntax for Gradle. For the Kotlin syntax, please refer to the official documentation for declaring dependencies.

Upload a Package


STOP: Note About Gradle's HTTP Connection Pooling

There is a known issue with Gradle and its HTTP connection pooling, affecting publishing (i.e. pushing of packages to Cloudsmith) when using the standard Maven-based upload endpoint.

The HTTP connection pooling in Gradle holds on to IPs for too long, and should the CDN change IP (common with varying points of presence), it will refuse to service the request. To alleviate this, we offer a globally static anycast IP, specifically for this situation.

Fix: Instead of using the standard endpoint, please use the endpoint instead.

Upload via gradle publish

The endpoint for native Gradle API (Maven-based) is:

For Maven-based publishing you'll need to enable the maven-publish plugin:

plugins {
  id 'maven-publish'

Next, configure a repositories block to point to Cloudsmith as follows:

publishing {
  repositories {
    maven {
      name = "cloudsmith"
      url = ""
      def releasesRepoUrl = ""
      def snapshotsRepoUrl = ""
      url = version.endsWith('SNAPSHOT') ? **snapshotsRepoUrl **: releasesRepoUrl
      credentials {
        username = 'USERNAME'
        password = 'API-KEY'

A bare minimum publications section is required:

publishing {
  publications {
    maven(MavenPublication) {
      // [snip]

You can now publish to the native API with:

gradle publish

Upload via the Cloudsmith CLI

For full details of how to install and setup the Cloudsmith CLI, see Command Line Interface.

The command to upload via the Cloudsmith CLI is:



cloudsmith push maven org/repo validation-api-1.0.0.GA.jar --pom-file=validation-api-1.0.0.GA.pom

Upload via Cloudsmith Website

Please see Upload a Package for details of how to upload via the Website UI.

Download / Installing


To enable the retrieval of Cloudsmith hosted packages via Gradle, the first step is to add your repository to the build.gradle file.

Public Repositories

Add the following, at any location, to your build.gradle file:

repositories {
  maven {
    url ""

After the repository is added to the build.gradle file, all that is left is to specify the dependency in the dependencies section of the project build.gradle file.

To do this add the below to your build.gradle file:

dependencies {

Private Repositories


Private Cloudsmith repositories require authentication. You can choose between two types of authentication, Entitlement Token Authentication or HTTP Basic Authentication.

The setup method will differ depending on what authentication type you choose to use.


Entitlement Tokens, User Credentials and API-Keys should be treated as secrets, and you should ensure that you do not commit them in configurations files along with source code or expose them in any logs

To enable the retrieval of packages from a private Cloudsmith repository via Gradle, add your repository your build.gradle file as follows:

repositories {
  maven {
    url ""
repositories {
  maven {
    url ""

    credentials {
      username "$repositoryUser"
      password "$repositoryPassword"

When using Entitlement Token Authentication, no further setup is required.
If using HTTP Basic Authentication, you can provide one following three types of credentials:

  • Cloudsmith Username and Password
  • Cloudsmith API Key
  • An Entitlement Token

When using HTTP Basic Authentication you'll probably want to keep your credentials separately in your ~/.gradle/ file instead of within the build.gradle file. once you have decided which credentials you wish to use, setup your ~/.gradle/ file as follows:


For more details on authentication in Gradle, please refer to the official Gradle documentation

Specifying Dependencies

After the repository is added to the build.gradle file and your credentials have been added to your ~/.gradle/ file (required for private repositories if using HTTP Basic Authentication), all that is left is to specify the dependency in the dependencies section of the project build.gradle file. To do this add the following to your build.gradle file:

dependencies {

Upstream Proxying / Caching

Configurable Proxying Caching
You can configure upstream repositories that you wish to use for packages that are not available in your Cloudsmith repository. In addition, you can also choose to cache any requested packages for future use.

Please see our Upstream Proxying documentation for further instructions.

Key Signing Support

GPG Index Packages


Please see the Troubleshooting Gradle page for further help and information.

Did this page help you?