# Gradle does not use the Maven Local Repository for a new dependency

**URL:** <https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194>\
**Category:** Help/Discuss\
**Created:** [August 16, 2015, 4:23am UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194 "2015-08-16T04:23:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr\_pompeii](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@dr\_pompeii](https://discuss.gradle.org/u/dr_pompeii)\
**Post date:** [August 16, 2015, 4:23am UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194/1 "2015-08-16T04:23:38Z")

</div>

Hello

I have Maven with M2\_HOME defined to:

- /Users/manuelj/apache/maven/3.2.5

I have the `settings.xml` file, located on:

- /Users/manuelj/apache/maven/3.2.5/conf/settings.xml

where I have the following declared:

```xml
<localRepository>/Users/manuelj/apache/maven/repository</localRepository>

```

Until here with Maven all works fine. Any new dependency goes there.

I have a project based with Gradle, among many things in my build.gradle, exists the following:

```gradle
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'application'

version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
	mavenLocal()
	mavenCentral()
}

… more

```

Until here, all works fine too. Code compile, executes well.

My confusion is the following.

According with my understanding is that Gradle’s **mavenLocal()** should use the same path than **`<localRepository>`** defined on Maven’s **settings.xml** file.

Now confirming that in the Maven local repository exists some dependencies already downloaded.

When I execute for example `gradle build`, I did realize that

1. If a dependency already exists from the Maven Local Repository, it is used from there.
2. If a dependency **does not** exists from the Maven Local Repository Gradle download the _new_ dependency to: `/Users/manuelj/.gradle/caches/modules-2/files-2.1`

I want that the new dependency go directly to the same `Maven Local Repository`.

Therefore, what extra configuration is need it?

Thanks in advanced

---

<div class="post-metadata">

**Author:** ![arnabcse28](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@arnabcse28](https://discuss.gradle.org/u/arnabcse28)\
**Post date:** [April 8, 2017, 12:49am UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194/2 "2017-04-08T00:49:41Z")

</div>

Any plans to have gradle support this feature of specifying custom place to download dependencies?

---

<div class="post-metadata">

**Author:** ![carlo\_lf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/carlo_lf/32/1881_2.png) [@carlo\_lf](https://discuss.gradle.org/u/carlo_lf)\
**Post date:** [April 9, 2017, 3:23pm UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194/3 "2017-04-09T15:23:11Z")

</div>

I don’t think Gradle will use the local Maven repository as a writeable one. Gradle has it’s own local repository, aka Gradle cache, which is a quite different thing. You can specify the location in an environment variable, i.e. (on Windows) “set GRADLE\_USER\_HOME=D:\Java\gradle-prj\gradleCache”.

---

<div class="post-metadata">

**Author:** ![ddimitrov](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ddimitrov/32/141_2.png) [@ddimitrov](https://discuss.gradle.org/u/ddimitrov)\
**Post date:** [April 10, 2017, 5:28am UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194/4 "2017-04-10T05:28:04Z")

</div>

In Gradle “repository” and “cache” are two different concepts. In Maven they are one concept, with the local repo being auto-updated.

In Gradle a repository is a source for artifacts, with varying degrees of metadata (i.e. an Ivy repo can have very rich metadata, Maven - less so, file dump - even less). A cache keeps a copy of what was retrieved from the repository with some extra information - i.e. where it was retrieved from, and others. The rich cache allows Gradle to cope with some scenarios Maven cannot.

The cache is internal Gradle concept and is not supposed to be touched by humans. Its internal format is not public and parts of it change over time to accommodate new requirements. As such using Gradle cache as a repository is a bad idea.

If you just want to store the cache in a different location, then the easiest way is to use a custom `$GRADLE_USER_HOME` - it would also take care of the cached Gradle Wrapper distributions. Here is some [step by step instructions](http://mrhaki.blogspot.jp/2010/09/gradle-goodness-changing-gradle-user.html) and [the manual](https://docs.gradle.org/current/userguide/gradle_command_line.html#sec:cli_system_properties).

---

<div class="post-metadata">

**Author:** ![Lance](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance/32/787_2.png) [@Lance](https://discuss.gradle.org/u/Lance)\
**Post date:** [April 10, 2017, 6:45am UTC](https://discuss.gradle.org/t/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency/11194/5 "2017-04-10T06:45:34Z")

</div>

I believe that the OP just wants to publish artifacts to maven local directory. See [publishing to maven local](https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:install)

> The “maven-publish” plugin makes this easy to do by automatically creating a PublishToMavenLocal task for each MavenPublication in the publishing.publications container
