I have a project that is moving from the self-hosted Nexus to Google Artifact Registry. Migration was smooth till I’ve got deal with parent-dependency.
Everything is running in GitActions on ubuntu-22.04.
I have a project that builds and deploys as POM file like this:
mvn deploy:deploy-file -Dpackaging=pom -Dfile=$svcname-$version.pom -DrepositoryId=${{ inputs.maven-registry-type }} -Durl=${{ inputs.maven-registry }} -DgroupId="$grpname" -DartifactId="$svcname" -Dversion="$revision"
I can see that package appears in GCR. Works great.
Next, another project(another repo) needs this package and has to use it as parent.
In my pom.xml file I have:
<parent>
<groupId>com.company.name</groupId>
<artifactId>common-parent</artifactId>
<version>VERSRION</version>
</parent>
<repositories>
<repository>
<id>common-parent</id>
<url>artifactregistry://region-maven.pkg.dev/project/common-parent</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<extensions>
<extension>
<groupId>com.google.cloud.artifactregistry</groupId>
<artifactId>artifactregistry-maven-wagon</artifactId>
<version>2.2.1</version>
</extension>
</extensions>
</build>
Package from Nexus was working great! But from GCR doesn’t want to be downloaded. I’m getting error:
Cannot access artifactregistry://region-maven.pkg.dev/project/common-parent with type default using the available connector factories: BasicRepositoryConnectorFactory and 'parent.relativePath' points at wrong local POM @ line 10, column 10'
Locally behavior the same till I install parent package manually. With Nexus I haven’t install it separately.
I was playing around and noticed that if I put the package to dependencies – it will be downloaded, but as parent doesn’t work.
What am I missing?
UPD:
I saw possible fix with adding empty parent.relativePath to pom.xml
<parent>
...
<relativePath />
</parent>
It didn’t help.
Also, didn’t help tricks with adding to maven -U like:
mvn install -U
But, I’ve found a solution, it is in the answer.
2
Answers
After hours of investigation I ran maven in debug more
And got detailed errors in the output:
This error pointed me on a git issue opened back in 2021: wagon is not loaded for parent pom resolution. Which, eventually, points on the official doc page with notice:
Ok, so, parent is exactly my case, where solution is to add to the project folder .mvn with the file extensions.xml in it:
Thank you Alex, Very good point