Learn about troubleshooting steps that you might find helpful if you run into problems managing java packages in Artifact Registry.
Can't resolve a dependency stored in Artifact Registry
Maven resolves some dependencies before applying a wagon defined in
pom.xml
, including:
- References in a child Maven project to a parent project using the
<parent>
element. - Plugin dependencies stored in Artifact Registry.
If your project needs to resolve these dependencies, you must use the core extensions mechanism to ensure that Maven can locate parent POM files and plugins.
In your project, create the file ${maven.projectBasedir}/.mvn/extensions.xml
with the following content. The <extension>
element defines the
wagon.
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>com.google.cloud.artifactregistry</groupId>
<artifactId>artifactregistry-maven-wagon</artifactId>
<version>2.2.4</version>
</extension>
</extensions>
Can't upload non-unique snapshots to a snapshot repository
You can upload snapshot versions that do not exist in an Artifact Registry snapshot repository, but you cannot overwrite a version that already exists in the repository.
Non-unique snapshots are a feature of Maven 2. Maven 3 always adds a timestamp to snapshot version numbers so that every snapshot version is unique.
Artifact Registry only supports non-unique snapshot versions in repositories with a snapshot version policy. By default snapshot repositories only accept unique snapshot versions. You can only set a version policy when you create the repository.
To find out the version policy settings for a repository, run the following command:
gcloud artifacts repositories describe REPOSITORY \
[--project=PROJECT] \
[--location=LOCATION]
Where
- REPOSITORY is the ID of the repository. If you configured a default Artifact Registry repository, it is used when this flag is omitted from the command.
- PROJECT is the project ID. If this flag is omitted, the current or default project is used.
- LOCATION is the regional or multi-regional location for the repository.
The output of the command includes information about the version policy
under mavenConfig
. In the following example, the repository has a snapshot
version policy and snapshots cannot overwrite identical versions in the
repository.
Encryption: Google-managed key
createTime: '2021-09-23T19:39:10.897404Z'
format: MAVEN
mavenConfig:
allowSnapshotOverwrites: false
versionPolicy: SNAPSHOT