This repository contains tools to help with interacting with Maven repositories hosted on Cloud Build Artifacts.
Requests to Cloud Build Artifacts will be authenticated using credentials from the environment. The tools described below search the environment for credentials in the following order:
- From the
gcloud
SDK. (i.e., the access token printed viagcloud 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)'
- Hint: You can see which account is active with the command
- Google Application Default Credentials.
The Cloud Build Artifacts Wagon is an implementation of the Maven Wagon API which allows you to configure Maven to interact with repositories stored in Cloud Build Artifacts.
To enable the wagon, add the following configuration to the pom.xml
in your project root:
<extensions>
<extension>
<groupId>com.google.cloud.buildartifacts</groupId>
<artifactId>buildartifacts-maven-wagon</artifactId>
<version>1.1.3</version>
</extension>
</extensions>
You can then configure repositories by using the "buildartifacts://" prefix:
<repositories>
<repository>
<id>my-repository</id>
<url>buildartifacts://maven.pkg.dev/PROJECT_ID/REPOSITORY_ID</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Where
- PROJECT_ID is the ID of the project.
- REPOSITORY_ID is the ID of the repository.
To use Cloud Build Artifacts repositories with gradle, add the following configuration to the
build.gradle
file in your project.
plugins {
id "com.google.cloud.buildartifacts.gradle-plugin" version "1.1.3"
}
repositories {
maven {
url 'buildartifacts://maven.pkg.dev/PROJECT_ID/REPOSITORY_ID'
}
}
publishing {
repositories {
maven {
url 'buildartifacts://maven.pkg.dev/PROJECT_ID/REPOSITORY_ID'
}
}
}
Where
- PROJECT_ID is the ID of the project.
- REPOSITORY_ID is the ID of the repository.
If you need to use BuildArtifacts repositories inside your init.gradle
or settings.gradle
, please add the following configuration to the ~/.gradle/init.gradle
file.
initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "gradle.plugin.com.google.cloud.buildartifacts:buildartifacts-gradle-plugin:1.1.4"
}
}
apply plugin: com.google.cloud.buildartifacts.gradle.plugin.BuildArtifactsGradlePlugin