Gradle – publish artifacts to Maven local repository

Short tutorial about how to create a Gradle task publishing (installing) artifacts into Maven local repository.

First of all, we need to import a ‘maven-publish’ plugin:

plugins {
    id 'maven-publish'

Next, we have to have a mavenLocal() as the first registry in repositories:

repositories {
        //other repositories

The plugin uses first defined repository as the target.

The minimal configuration of the task should look like this:

publishing {
    publications {
        mavenJava(MavenPublication) {

By running task publishToMavenLocal, the plugin will install compiled jar into Maven local repository along with the pom file generated based on the project properties (group, version, etc).

For plugin reference and custom configuration see

Leave a Reply

Your email address will not be published. Required fields are marked *