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
gcloudSDK. (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.2.1</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.2.1"
}
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, the plugin can also be used inside init.gradle or settings.gradle files.
- To use plugin inside
init.gradlefile:
initscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.google.cloud.buildartifacts:buildartifacts-gradle-plugin:1.2.1"
}
}
apply plugin: com.google.cloud.buildartifacts.gradle.plugin.BuildArtifactsGradlePlugin- To use plugin inside
settings.gradlefile:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.google.cloud.buildartifacts:buildartifacts-gradle-plugin:1.2.1"
}
}
apply plugin: "com.google.cloud.buildartifacts.gradle-plugin"