Skip to content

bjoernmayer/artifactregistry-gradle

Repository files navigation

Artifact Registry Gradle

Gradle Plugin Portal

This repository contains a Gradle plugin to help with interacting with Maven repositories hosted on Artifact Registry.

It used to be a copy of Artifact Registry Maven Tools but only for Gradle and more up to date.

Usage

Apply the plugin:

  • In build.gradle.kts for single module projects
  • In settings.gradle.kts for multi module projects
id("io.github.bjoernmayer.artifactregistryGradlePlugin") version "<VERSION>"

Using with Jib in a multi module project

If you see weird errors like NoSuchMethod, you might need to pin down the guava version for your buildscript:

// root settings.gradle.kts
buildscript {
    dependencies {
        classpath("com.google.guava:guava:33.2.0-jre")
    }
}

Authentication

Requests to Artifact Registry will be authenticated using credentials from the environment. The plugin searches the environment for credentials in the following order (default):

  1. Google Application Default Credentials.
    • Note: It is possible to set Application Default Credentials for a user account via gcloud auth login --update-adc or gcloud auth application-default login
  2. From the gcloud SDK. (i.e., the access token printed via gcloud config config-helper --format='value(credential.access_token)')
    • Hint: You can see which account is active with the command gcloud config config-helper --format='value(configuration.properties.core.account)'

Configuration

You can change this order or disable providers like this:

artifactRegistry {
    applicationDefault {
        // enable.set(false) // default true
        order.set(2) // default 1
    }

    gCloudSDK {
        // enable.set(false) // default true
        order.set(1) // default 2
    }
}