How to use Maven Local repository for gradle build

I need to reuse the maven local repository for dependencies. I have used the below configuration. But it seems to be not working.

repositories {
 mavenCentral artifactUrls:["file://C:/maven/.m2/repository/"]
 }

Please advise.

1 Like

There’s a special notation.

repositories {
  mavenLocal()
}
3 Likes

Thanks Luke. Its working Fine.

Also, can’t you do this by setting the project to run in offline mode?

What is if I’ve configured mavenLocal() and 'maven { url ‘https://oss.sonatype.org/content/repositories/snapshots’ } and there exists snapshot in the maven snapshot repository and in my local maven cache? Which snapshot will be used, ie. considered newer?

Gradle searches for dependencies in repositories in the order in which they are listed. So if you want to find snapshots in your local maven repo first, ensure that ‘mavenLocal()’ is listed first in your ‘repositories’ configuration.

See the Gradle documentation for more information.

1 Like

If I’m using a snapshot I would like to get the latest version no matter if it is in my local repo or a remote one. Is that posible?

2 Likes

Thanks :slight_smile: