Jitpack — How to add dependencies not published in Maven Central
While developing a Java or Android project, you need to add dependencies to your project. Generally, those dependencies are retrieved from Maven Central or some 3rd party repository like Spring Maven Repository. What about your desired library is not published anywhere or it’s an in-house library developed by your team and not ready to be published yet? You have a 2 options:
- Use external JARs as Maven System Dependencies (deprecated)
- Add to Maven Central as an artifact (cumbersome)
First way is not SDLC friendly as it will be hard to manage CI environments due to your external jar (you need to copy your jar everywhere).
Second way forces your library to be public. Even you’re ok with it it’s very cumbersome process.
Thanks to Jitpack there is a 3rd way to use any library as a Maven dependency now.
“Jitpack builds Git projects on demand and provides you with ready-to-use artifacts (jar, aar).”
All you need is a buildable Github project. Jitpack can build Gradle, Maven, Sbt and Leiningen projects.
Building with JitPack
Let’s see an example with a Maven project.
Give Jitpack your project’s Github url and it lists available releases, builds, branches and even individual commits. Then pick one of them and you are ready to use that library’s particular version as a dependency.
- Group: com.github.Username
- Artifact: Repository Name
- Version: Release name, commit hash or branch name followed by
JitPack checks out the code, builds it and serves the build artifacts.
JitPack also works with other Git hosting providers. The only difference is the groupId of your artifacts:
- BitBucket: org.bitbucket.Username
- GitLab: com.gitlab.Username
And more from Jitpack…