Exception while trying to deploy Maven build JAR to github package registry

…衆ロ難τιáo~ 提交于 2020-01-23 17:36:05

问题


I am trying to deploy the Maven build JAR to Github Package Registry.

I am getting exception when I execute mvn deploy command.

I am using a simple Maven project which I want to create a component JAR and store in Github Package Registry.

The build is successful I now want to deploy this artifact to registry.

I have added the below in ~./m2/settings.xml.

Added a repository element under repositories in profile.

    <repository>
          <id>github</id>
          <name>GitHub OWNER Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/swastikaa-in</url>
        </repository>
 <servers>
    <server>
      <id>github</id>
      <username>swastikaa</username>
      <password>my personal token from github</password>
    </server>
  </servers>        

Also, I have added the below in Maven project's pom.xml:

 <distributionManagement>
   <repository>
     <id>github</id>
     <name>GitHub OWNER Apache Maven Packages</name>
     <url>https://maven.pkg.github.com/swastikaa-in/math</url>
   </repository>
</distributionManagement>

Expected: Deployment to be successful , build artifact is deployed to Github package registry.

Actual: Exception as below:

Caused by: org.eclipse.aether.transfer.MetadataTransferException:
  Could not transfer metadata com.redjohn.tools:math:0.0.2-SNAPSHOT/maven-metadata.xml
  from/to github (https://maven.pkg.github.com/swastikaa-in/math):
  Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
  with status code 400

Caused by: org.apache.maven.wagon.TransferFailedException:
  Failed to transfer file https://maven.pkg.github.com/swastikaa-in/math/com/redjohn/tools/math/0.0.2-SNAPSHOT/maven-metadata.xml
  with status code 400

Can someone help me in resolving the issue.

I have followed the instructions provided in the below link:

https://help.github.com/en/articles/configuring-apache-maven-for-use-with-github-package-registry


回答1:


I had the same problem and I found that snapshot versions don't work well. If you deploy a non snapshot version, it should work.




回答2:


Inside your settings.xml file, <url>https://maven.pkg.github.com/OWNER/REPOSITORY</url> you need to make use that OWNER is replaced with your github username and REPOSITORY is replaced with the name of your project repository in github.



来源:https://stackoverflow.com/questions/58007090/exception-while-trying-to-deploy-maven-build-jar-to-github-package-registry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!