Easy Maven Publishing with JitPack.io
If youβve ever wanted to share a Java library without setting up a full Maven Central or OSSRH workflow, JitPack.io is a developer-friendly alternative that lets you publish directly from GitHub. No Sonatype signups. No GPG keys. No ticket systems. Just a git push
and youβre live.
In this post, Iβll show you how I published my own Java project, cli-power-tools
, using JitPack β and how you can do the same in under 10 minutes.
π‘ What Is JitPack?
JitPack is a free service that builds your Maven or Gradle project directly from your GitHub repo. It hosts your builds as Maven artifacts and gives you a public Maven repository to consume them β perfect for fast prototyping, internal tools, or open-source utilities.
β Why Use JitPack?
- π¦ No manual publishing
- π No account or credentials needed
- π Built from GitHub commits, branches, or tags
- π Generates a hosted Maven repo for you
π§ͺ Example: Publishing cli-power-tools
Letβs walk through how cli-power-tools
, a small utility for CLI-based Java apps, is published with JitPack.
1. π Structure Your Project
Make sure your project is a standard Java build (Maven or Gradle). Hereβs what cli-power-tools
uses:
- Java 17
- Maven (
pom.xml
) - GitHub-hosted
π‘ JitPack supports both Maven and Gradle builds out of the box.
2. π¦ Build with JitPack
Go to https://jitpack.io and paste in your GitHub repo URL:
teggr/cli-power-tools
Click "Look Up", then select a tag, branch, or commit and click "Get it".
JitPack will generate Maven coordinates like this:
<dependency>
<groupId>com.github.teggr</groupId>
<artifactId>cli-power-tools</artifactId>
<version>main-SNAPSHOT</version>
</dependency>
π» Consuming cli-power-tools
To use this library in your own project:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.teggr</groupId>
<artifactId>cli-power-tools</artifactId>
<version>main-SNAPSHOT</version>
</dependency>
</dependencies>
π· Tag a Release (Optional, but Recommended)
JitPack builds from tags, commits, or branches. For stable versioning, create a Git tag:
git tag v1.0.0
git push origin v1.0.0
π§© Troubleshooting Tips
- β Ensure your GitHub repo is public
- π If your build fails, inspect logs from the JitPack UI
- π¦ Make sure all plugins/dependencies in your
pom.xml
are available in public repositories
π Final Thoughts
JitPack is a super simple way to share Java libraries with minimal friction. For internal tools, experimental libraries, or lightweight open-source utilities, itβs a great alternative to the traditional Maven Central pipeline. There's also paid options for more serious use cases and private repositories.
If you want to check out or use cli-power-tools
, you can try it immediately with:
<dependency>
<groupId>com.github.teggr</groupId>
<artifactId>cli-power-tools</artifactId>
<version>main-SNAPSHOT</version>
</dependency>
Happy hacking! π