无法使用Maven部署到GitHub Packages

huangapple go评论108阅读模式
英文:

Cannot deploy to GitHub Packages with Maven

问题

按照这个指南,我创建了一个非常简单的GitHub Repo并尝试部署到GitHub Packages。

然而,我不断地、随机地遇到以下错误之一:

有趣的是,部署快照(SNAPSHOTS)的操作正常工作!

我已经尝试过:

  • 不同的Java版本(8和11)
  • 不同的maven-deploy-plugin版本

在设置了我的个人访问令牌(PAT)在我的 .m2/settings.xml 后,我还在本地尝试过。

我还尝试直接PUT POM 或/和 JAR,并且它是有效的:

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

响应:

...
* 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

有没有人知道我哪里做错了呢?

英文:

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:

  • different Java versions (8 and 11)
  • different maven-deploy-plugin versions

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 \
&quot;https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.jar&quot; \
-H &quot;Authorization: token ***&quot; \
--upload-file &quot;&lt;&lt;PATH_TO_JAR&gt;&gt;&quot; -vvv
curl -X PUT \
&quot;https://maven.pkg.github.com/sadrian/packaging/com/sadriu/packaging/1.0.0/packaging-1.0.0.pom&quot; \
-H &quot;Authorization: token ***&quot; \
--upload-file &quot;&lt;&lt;PATH_TO_POM&gt;&gt;&quot; -vvv

Response:

...
* We are completely uploaded and fine
&lt; HTTP/2 200 
&lt; access-control-allow-methods: OPTIONS, PUT
&lt; access-control-allow-origin: *
&lt; content-security-policy: default-src &#39;none&#39;;
&lt; server: GitHub Registry
&lt; strict-transport-security: max-age=31536000;
&lt; x-content-type-options: nosniff
&lt; x-frame-options: DENY
&lt; x-xss-protection: 1; mode=block
&lt; date: Fri, 03 Mar 2023 12:59:48 GMT
&lt; content-length: 66
&lt; content-type: text/plain; charset=utf-8
&lt; x-github-request-id: CE82:12C8F:16396B:171471:6401EF43
&lt; 
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?

答案1

得分: 0

根据 @joshiste 的提到,问题似乎是由于 Maven 版本 >= 3.9.0 引起的。

在查看 这个链接 后,我尝试运行 mvn deploy 时加上 -Dmaven.resolver.transport=wagon,它成功了!

可能降级 Maven 也会起作用,但我还没有尝试。

英文:

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.

huangapple
  • 本文由 发表于 2023年3月3日 21:08:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75627473.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定