Java – hosting private Maven artifacts in the GitHub repository

I use the following solution hosting a maven repository on GitHub to host a private Maven repository on GitHub

I have managed to deploy Maven artifacts to the GitHub repository under the MVN repo branch

The problem is that it's hard for me to use this artifact as a maven dependency in other projects I'm relying on POM Repository settings have been added to XML

<repository>
        <id>github</id>
        <name>{name}</name>
        <url>https://raw.github.com/{repo-owner}/{repo-name}/mvn-repo/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
        </snapshots>
    </repository>

I have configured settings XML file

<server>
   <id>github</id>
  <username>{github-user-name}</username>
  <password>{github-user-password}</password>
</server>

When I try to install the project, I can't find the error on the artifact. When I set the artifact GitHub repository as the public repository, everything is fine, so it's obviously an authentication problem Strangely, I used the same credentials to successfully deploy the artifacts to the same GitHub repository in the first step

I also tried to generate an access token from GitHub and set it in settings XML to use the concept of "personal access tokens", as shown below:

<server>
  <id>github</id>
  <password>{personal_access_token}}</password>
</server>

But it didn't succeed... So basically I'm halfway there. I've managed to create Maven artifacts in the GitHub repository that can be distributed, but I need it to be a private repository

Anyone can help. We thank you very much for your answer

Solution

This cannot be done with Maven alone, raw github. Com expects an access token at the end of the URL when accessing the private repository, but Maven does not provide the option of this token

Alternative mode

Provide installation scripts for users

You can provide users with an installer script that downloads dependencies and installs them into the local Maven repository You can install jars locally in the following ways:

mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>

Your installer should bundle some of these commands together to get what you want

Related: Guide to installing 3rd party jars

Hosting your own Maven dependent server

You don't need a fast computer to host the dependencies of Maven project. In the past, I had a raspberry PI. I used the nginx and sendfile options to obtain a static document server with good performance. Please remember that Maven is optimized for local content. It only downloads one file and switches to its local file in the remaining time

Disclaimer: I am not affiliated with raspberry PI

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>