DEV Community

Cheav Sovannarith
Cheav Sovannarith

Posted on • Originally published at Medium on

Loading Maven dependencies from GitHub

jitpack.io — github.com

Now you can import a Java library from a GitHub repo using JitPack.

In your pom.xml:

First Add repository:



<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>


Enter fullscreen mode Exit fullscreen mode

Second Add dependency:



<dependency>
    <groupId>com.github.User</groupId>
    <artifactId>Repo name</artifactId>
    <version>Release tag</version>
</dependency>


Enter fullscreen mode Exit fullscreen mode

Note : for release tag

Before we can use release tag as a version in dependency, we have to create release tag first.



$ git tag -a 0.0.1-SNAPSHOT -m "commit message"
$ git push origin --tag


Enter fullscreen mode Exit fullscreen mode

*READ MORE * : https://git-scm.com/book/en/v2/Git-Basics-Tagging

Example : I have a Repository : https://github.com/sovannarithcheav/artifact-demo.git, So the dependency should look like this :



<dependency>
 <groupId>com.github.sovannarithcheav</groupId>
 <artifactId>artifact-demo</artifactId>
 <version>0.0.1-SNAPSHOT</version>
</dependency>


Enter fullscreen mode Exit fullscreen mode

It’s easy, right? 😜

READ MORE : loading-maven-dependencies-from-github


Top comments (0)