We recently went through the process of publishing a Java library to JitPack so that other developers could use it in their own projects. It was a learning experience with several configuration steps and a few unexpected challenges along the way.
1. JAR Artifact Generation
The first step was setting up a task to create a JAR artifact with a specified name. This ensures the output file is consistently named and can be referenced by other build configurations.
2. Project Grouping
For JitPack compatibility, the project needs to be grouped as com.github.myusername with an appropriate version number. This follows JitPack's convention of using GitHub usernames as the group identifier.
3. Maven Publishing Plugin
We added maven-publish to the plugins block and configured the publication settings. This defines how the library gets packaged and what metadata is included when it's published.
4. JitPack Configuration
A jitpack.yml file was created pointing to the build output. This tells JitPack how to build the project and where to find the resulting artifacts.
Challenges
One significant challenge was dealing with the Shadow JAR plugin. We needed to include local JARs as dependencies, and the shadow jar plugin was essential for bundling everything together into a single fat JAR that could be distributed.
Another issue we ran into was source set configuration. Our Java files weren't being recognized by the build system, which required adjusting the source set paths so the compiler could find and process them correctly.
References
This work was done for our text-to-speech library for libGDX, which is available as an open source project at auraxangelic/libgdx-tts on GitHub.