IntelliJ IDEA
 
Get IntelliJ IDEA

Publish a Java library to a Maven repository

Last modified: 11 February 2024

A purpose of this tutorial is to demonstrate how to publish a Java library created in the Gradle project to a local Maven repository and then to the remote one using IntelliJ IDEA.

Let's start with creating a Gradle project.

Now let's tweak the build.gradle file a little since we need to add support for a Java library and build our project.

Now let's follow the Maven conventions and specify Maven coordinates for our library. Since IntelliJ IDEA has already added GroupId and Version when we created our project, the only thing that we need to change is ArtifactId.

Now let's work with our build script further and publish the library into a local Maven repository.

We can edit the build.gradle file further to publish our library to the remote repository.

For more information about customizing the POM file, using a different snapshot, or releasing repositories, refer to Gradle documentation.