Publishing 3rd Party Libraries Locally

When you create your own library and you plan to publish it, for example on JCenter (bintray), you will probably follow the steps of the gradle-bintray-plugin github website. The following part of this story is based on libraries published this or on a similar way.

If you are integrating either your own library or a 3rd party library in your project, for example butterknife , and it has a bug you want to fix or you just want to make some changes on it, but test it in your project before to make a pull request or even publish a new version, you can publish it locally.

Let’s asume you have access to the code of that library and you have configured the gradle code or the script for the publication (gradle-bintray-plugin), then just clone it into your computer, navigate by a terminal console to the root path and execute the following commands:

./gradlew clean ./gradlew build ./gradlew publishToMavenLocal

Once finished, this will generate a pom and a aar file of this library inside the hidden ~/.m2/repository/ folder.

The publishToMavenLocal is a built-in task of the maven-publish plugin, and it will not publish anything into the remote artifactory at all (JCenter / Maven).

In your project:

Enable mavenLocal repositories into your build system.

repositories into your build system. Make sure mavenLocal is in the top of the list.

buildscript {

repositories {

mavenLocal()

jcenter()

google()

...

Have into account that having mavenLocal on the top of the list will make to always pick up libraries available in the ~/.m2/repository/ folder first.

Yep! That’s it again! 😄