如何 Link GitHub 存储库作为 Maven 依赖项

How to Link GitHub Repository As Maven Dependency

我创建了一个 GitHub 存储库 (Private) 并想将其用作其他一些项目的 Maven 依赖项 (Private).因此,我在互联网上尝试了以下方法,但我仍然能够导入其他项目的 Maven 依赖项。

我尝试了以下这些方法

  1. https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063 通过构建一个包含 jar 的分支并将分支 raw.githubusercontent.com 链接为 repo url.

  2. Hosting a Maven repository on github

  3. http://www.lordofthejars.com/2011/09/questa-di-marinella-e-la-storia-vera.html

  4. http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html (与步骤 1 相同)

  5. https://github.com/jitpack/maven-simple 我尝试与 JITPACK 链接并尝试过,但仍然无效。

这是参考文献5,

在我的 pom.xml 文件中我将要使用存储库的项目,我添加了如下依赖项,它能够更新 maven 索引并且能够为 CMD.

下载相关 pom.xml 文件
   <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

   <dependency>
        <groupId>com.github.Amutheezan</groupId>
        <artifactId>CMD</artifactId>
        <version>v1.0ALPHA2</version>
    </dependency>

注意:-我的版本,我尝试了最近发布的版本,最新提交的值和 1.0-SNAPSHOT。

我仍然无法以任何一种方式导入。

import com.abc.CMD.*
or
import com.abc.*

可以帮我解决我哪里出错了吗?

因为你的仓库是私有的,你没有按照步骤授权jitpack访问私有仓库

https://jitpack.io/private

Private Repositories To use JitPack with private repositories:

Step 1. Authorize JitPack and get your personal access token:

Step 2. Add the token to $HOME/.m2/settings.xml as the username

<settings>
  <servers>
    <server>
      <id>jitpack.io</id>
      <username>AUTHENTICATION_TOKEN</username>
      <password>.</password>
    </server>
  </servers>
</settings>

The id of the server must be the same you use in your pom.xml

Step 3. (Optional) You may need to approve JitPack Application on GitHub

Build artifacts (jar, aar) are also private and you can only download them if you have access to the Git repo itself. See the documentation for more details

If you'd like to host JitPack inside your organization please see JitPack Enterprise