Gradle – reading from Maven local repository

In this short post we will see how to use Maven local repository as a source of dependencies.

This approach can be useful during local development, when for some reasons the same dependencies are needed by projects managed by different build automation tools.
By default Maven local repository is located in ${user.home}/.m2/repository.
Gradle stores its dependencies in ${user.home}/.gradle directory.
To use Maven repository in gradle builds, you have to add this repository in your configuration using this notation:
repositories {
  mavenLocal()
}
And that’s it. No other configuration is needed.
But you have to be aware that this relation is unidirectional – Gradle will use Maven repository, but it won’t publish by default any artifact into Maven repository.

Leave a Reply

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