Amutheezan
Amutheezan

Reputation: 355

How to Link GitHub Repository As Maven Dependency

I create a GitHub Repository(Private) and wanted to Use it as a Maven Dependency for Some Other Projects (Private). Accordingly I have tried out following approaches in the internet and still I could able to import the maven dependencies on the Other projects.

I have tried out these following approaches

  1. https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063 through building a branch, which contains jar and linking the branch raw.githubusercontent.com as the 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 (same as Step 1)

  5. https://github.com/jitpack/maven-simple I tried linking with JITPACK and Tried but still it doesn't work.

This is based on Reference 5,

In my pom.xml file the project which I am going to use repository, I have added dependency as follows, ant it was able to update maven indices and able to download related pom.xml file for CMD.

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

NOTE : - I place of version, I have tried recently released version, latest commit's value and 1.0-SNAPSHOT.

Still I couldn't able to import in either way.

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

Can help me out where I am making mistake ?

Upvotes: 1

Views: 6213

Answers (1)

Ryan Leach
Ryan Leach

Reputation: 4470

It's because your repository is private, and you have not followed the steps to authorize jitpack to access a private repository.

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

Upvotes: 1

Related Questions