I am interested in using a project on GitHub as a dependency in my project. The GitHub project has a pom
file. Can I modify my pom
file to use this project? If so, how? If not, what is my best course of action?

- 11,279
- 6
- 36
- 58
3 Answers
Try jitpack, you just need to add the dependency, jitpack will build others for you.
From home page:
jitpack
Easy to use package repository for Gradle and Maven projects
JitPack builds GitHub projects on demand and provides ready-to-use packages
HOW
- Add repository first
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
- Add dependency
<dependency>
<groupId>com.github.User</groupId>
<artifactId>Repo name</artifactId>
<version>Release tag</version>
</dependency>
TIPS:
You can see its build log too https://jitpack.io/com/github/NanoHttpd/nanohttpd/Release-2.1.0/build.log

- 957
- 10
- 23

- 7,191
- 6
- 54
- 78
-
10@james free for public git repositories – metrimer Aug 17 '15 at 10:56
-
I can't make it work. I am trying
com.github.lbehnke hierarchical-clustering-java anyBranch-SNAPSHOT -
Does `jitpack` work for multiple repos in one `pom.xml` ? – WestCoastProjects Oct 11 '17 at 04:48
Not in the way I think you mean, AFAIK.
You can use github as a Maven repository--this is not the same thing as directly referencing a project, and that it has a pom file means only that it's a Maven project.
If the project is not available in the central, or other, repository, your best bet may be to clone it, build it, and install it locally. You should confirm that it's truly not available elsewhere.

- 158,873
- 26
- 254
- 302
-
11
-
Heroku also provides a nice setp-by-step guide on [adding unmanaged dependencies to a Maven project](https://devcenter.heroku.com/articles/local-maven-dependencies). – Matheus Santana Dec 03 '15 at 17:52
@wener's answer is very helpful, but leaves some mystery.
This real example might save some time:
<project ... >
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<!-- groupId is https://github.com/fabric8io/kubernetes-client -->
<groupId>com.github.fabric8io.kubernetes-client</groupId>
<!-- module is a directory within the repo, containing pom.xml -->
<artifactId>kubernetes-model-generator-client</artifactId>
</dependency>
</dependencies>
. . .
Make sure you are signed into GitHub.
You can also find a tag index page by cutting at the tag within the URL, like https://jitpack.io/com/github/fabric8io/kubernetes-client/. In my example, I figured out if "v" from "v6.4.1" had to be removed or not, since there is a release with the v and a tag without it.
More details: jitpack.io page