maven-deploy-plugingithub-packages400-bad-request

Cannot deploy to GitHub Packages with Maven


Following this guide, I created a very simple GitHub Repo and tried to deploy to GitHub Packages.

However I'm getting continuously and randomly one of the following errors:

Interestingly enough is the fact the deploying SNAPSHOTS works as expected!

I already tried:

Tried out also locally, after setting my PAT in my .m2/settings.xml.

I also tried to PUT directly the POM or/and JAR and it works:

curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.jar" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_JAR>>" -vvv
curl -X PUT \
"https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.pom" \
-H "Authorization: token ***" \
--upload-file "<<PATH_TO_POM>>" -vvv

Response:

...
* We are completely uploaded and fine
< HTTP/2 200 
< access-control-allow-methods: OPTIONS, PUT
< access-control-allow-origin: *
< content-security-policy: default-src 'none';
< server: GitHub Registry
< strict-transport-security: max-age=31536000;
< x-content-type-options: nosniff
< x-frame-options: DENY
< x-xss-protection: 1; mode=block
< date: Fri, 03 Mar 2023 12:59:48 GMT
< content-length: 66
< content-type: text/plain; charset=utf-8
< x-github-request-id: CE82:12C8F:16396B:171471:6401EF43
< 
Successfully registered maven upload: packaging-1.0.0.pom (1.0.0)
* Connection #0 to host maven.pkg.github.com left intact

Does anybody have an idea what am I doing wrong?


Solution

  • As mentioned by @joshiste the problem seems to be because of the maven version >= 3.9.0.

    After checking this, I tried to run mvn deploy with -Dmaven.resolver.transport=wagon and it worked!

    Probably downgrading maven would also work, however I haven't try yet.