- What is Numsy?
- Step‑by‑Step: Building the Package
- 1.Generate a Maven Project
- 2.Implement the Utility Class
- Publishing to GitHub Packages
- 3.Set Up pom.xml
- 4.Authenticate with GitHub
- 5.Deploy the Package
- Using the Numsy Package in Other Projects
- Final Thoughts
Recently, I built a small but useful java utility package called Numsy, and published it to Github Packages. Here's a quick walkthrough of how I did it, step-by-step. Hope it helps if you are planning to publish your package!
Numsy is a lightweight Java utility library for basic number manipulation, formatting, and checks.
Currently it supports:
- Check if Number is Even or Odd
- Check if Number is Prime or Not
- Find Prime Number within a range.
- Number formatting- Add Commas
- Find GCD
- Find LCM
it's nothing fancy — Just something useful that java doesn't offer directly in a clean, reusable way.
I used the maven archetype to create the project quickly:
mvn archetype:generate \
-DgroupId=com.therohitpatwa \
-DartifactId=Numsy \
-DarchetypeArtifactId=maven-archetype-quickstart \
-DinteractiveMode=false
This will create a folder structure like this. (It will also create test folder, but we won't bother with that for now. also ignore the .gitignore, give it taste of its own medicine 😁)
In src/main/java/com/therohitpatwa/Numsy Numsy.java, I added some static method:
public static Boolean isEven(int n) { ... }
public static Boolean isOdd(int n) { ... }
public static List<Integer> primeInRange(int start,int end) { ... }
So on...I updated my pom.xml to include the Github packages repository under distributionManagement.
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/Github_Username/numsy</url>
</repository>
</distributionManagement>In your Maven setting.xml (In ~/.m2/setting.xml file), added my GitHub credentials like this:
<servers>
<server>
<id>github</id>
<username>YOUR_GITHUB_USERNAME</username>
<password>YOUR_PERSONAL_ACCESS_TOKEN</password>
</server>
</servers>To create YOUR_PERSONAL_ACCESS_TOKEN:
- go to github.com/settings/tokens
- Create a Classic Token with these scope enables:
write:packages read:packages - Create and Paste it in the setting.xml
Run this command to publish:
mvn clean deploy
You'll see the packages listed under Packages in your GItHub repo if all goes well!
In other project's pom.xml, include the repository and dependency:
<dependencies>
<dependency>
<groupId>com.therohitpatwa</groupId>
<artifactId>numsy</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>Now Import
com.therohitpatwa.Numsy.numsy
and you can use methods provided in Numsy class of numsy
Syntax -Numsy.methodName();
I will add more method in Numsy soon. if you would like to use it or contribute, check it out here — 👉 Numsy





