Maven cannot resolve dependency for public GitHub package despite correct PAT

5 days ago 10
ARTICLE AD BOX

My pom.xml file includes the following dependencies:

<dependencies> <!-- Google GSON --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.13.2</version> </dependency> <!-- Serial Server Sockets --> <dependency> <groupId>com.sgware</groupId> <artifactId>serialsoc</artifactId> <version>1.0.0</version> </dependency> </dependencies>

The first dependency (Google GSON) resolves correctly.

The second is a package I created. The package is public on GitHub Packages, and I can view it and download its parts as long as I am signed into GitHub. However, when I try to do anything through Maven, such as mvn install I get this error:

[ERROR] Failed to read artifact descriptor for com.sgware:serialsoc:jar:1.0.0 [ERROR] Caused by: The following artifacts could not be resolved: com.sgware:serialsoc:pom:1.0.0 (absent): Could not transfer artifact com.sgware:serialsoc:pom:1.0.0 from/to github (maven.pkg.github.com): Cannot access maven.pkg.github.com with type default using the available connector factories: BasicRepositoryConnectorFactory

I have the following in my settings.xml file:

<servers> <server> <id>github</id> <username>sgware</username> <password>XXX</password> </server> </servers>

Where XXX is my GitHub Personal Access Token (classic) which has not expired and has the read:packages permission.

I have tried deleting my ~/.m2/repository directory and running things like mvn install -U to no avail.

What's more, if I simply download serialsoc-1.0.0.jar and serialsoc-1.0.0.pom via HTTP into ~/.m2/repository/com/sgware/serialsoc/1.0.0/ then everything works. So it seems to be a problem of Maven simply refusing to download these assets.

I am using Maven 3.9.12 on Windows 10. I have tried running Maven from a terminal with Administrator privileges, and that gives the same error.

What am I doing wrong?

Read Entire Article