Loading Maven dependencies from GitHub

Arielle picture Arielle · Nov 23, 2013 · Viewed 63.2k times · Source

How do I add a Java library from its GitHub repo (the library uses Maven as a build system) as a dependency to my Maven project? Can I do that without downloading and compiling the library?

Answer

Andrejs picture Andrejs · May 4, 2015

Now you can import a Java library from a GitHub repo using JitPack. In your pom.xml:

  1. Add repository:
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
  1. Add dependency
<dependency>
    <groupId>com.github.User</groupId>
    <artifactId>Repo name</artifactId>
    <version>Release tag</version>
</dependency>

It works because JitPack will check out the code and build it. So you'll end up downloading the jar.
If the project doesn't have a GitHub release then its possible to use a commit id as the version.