1

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 ?

Amutheezan
  • 345
  • 1
  • 8
  • 24
  • 1
    Jitpack should be a good approach. What classes do you try to import? Are they contained in jar referenced maven dependency? Which error do you get? – Roland Weisleder Jun 05 '18 at 05:36
  • 1
    Yes they were contained in jar, still can't figure out why it is not importing – Amutheezan Jun 05 '18 at 05:57
  • 1
    It's because it's private. – Ryan Leach Jun 05 '18 at 08:14
  • 1
    @RolandWeisleder I have updated the question more clearly and readable can you able to help me now – Amutheezan Jun 05 '18 at 08:15
  • 1
    @RyanTheLeach I have tried out by making it public still it fails, (For Private : also I tried adding the configuration on $HOME/.m2/settings.xml to link private file) – Amutheezan Jun 05 '18 at 08:17
  • 1
    Can you edit the post with your full pom, barring the username / password? It's my suspicion that something else is causing your build to fail, or it's not publishing correctly on jitpack, making it difficult to access your files. – Ryan Leach Jun 05 '18 at 08:26
  • 1
    The guides 1-4 that you are following are hacky and garbage and (ab)using github for something that it was never designed (and therefore will be difficult to troubleshoot) IF you wish to use jitpack, then only follow guides made for jitpack, it's an entirely different method then the others and should not be confused between them. – Ryan Leach Jun 05 '18 at 08:28
  • @RyanTheLeach so only solution available to Maven Dependency is using JITPACK, since I have done my pom.xml file with (2) I will updated with JITPACK and edit the Post with related pom file. – Amutheezan Jun 05 '18 at 08:31
  • 1
    It's not the only solution available, it's just the only **non hacky** solution to getting a easy to use repository from a github repo from the 5 options you listed, which is why jitpack exists as a service. You can always host your own maven repo on web hosting you control instead. – Ryan Leach Jun 05 '18 at 08:33
  • I have actually added ` jitpack.io https://jitpack.io ` as repository and ` com.github.Amutheezan abcCMD v1.0ALPHA2 ` and added the setting said for private file in addition to normally generated POM file for an Idea Maven Project – Amutheezan Jun 05 '18 at 08:34

1 Answers1

1

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

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
  • 1
    I followed the authorized jitpack and added the auth code – Amutheezan Jun 05 '18 at 08:18
  • 1
    Your are mentioning something like this right, I have tried out that also still it doesn't work. I have tried both in private and public mode still it can't able to download ` jitpack.io abcd . ` – Amutheezan Jun 05 '18 at 08:19
  • 1
    I have followed above methods, Still it doesn't work – Amutheezan Jun 05 '18 at 08:22
  • 1
    I don't know what else to offer you, but it may help someone else. – Ryan Leach Jun 05 '18 at 08:22
  • 1
    If you have ProjectA; and ProjectB which has a dependency on ProjectA, Make sure you are doing the Authorization on ProjectA's github, and including the token / dependency on ProjectB – Ryan Leach Jun 05 '18 at 08:39
  • I didn't get that exactly, do we need to add any other things rather than repository and dependency to pom.xml file, and the token configuration to $HOME/.m2/settings.xml file – Amutheezan Jun 05 '18 at 08:44