Have Dependencies Resolved from Remote Maven Repo installed into Local Maven Repo

Gradle: gradle-1.0-milestone-6 Windows 7

I am just starting to learn to use Gradle and am just currently experimenting with some of the samples.

I have a local Maven Repo setup and it is successfully being found by my build.gradle.

repositories {

maven {

url “C:/development/repos/.m2/repository”

}

mavenCentral()

}

Now, with the above configuration, if a dependency is found in the local Maven repo then it is resolved ok, and if it is not found then the central repo is used to resolve the dependency, however, it is then downloaded and installed into the Gradle cache.

My question is whether it is possible to have dependencies that are resolved using the remote Maven repo installed into the local Maven repo automatically (as is the usual behaviour if using Maven with a pom) rather than having it installed into the local Gradle cache?

I understand that there is uploadRepositories configuration required in the build.gradle to enable dependencies to be installed into a repository but I assumed that would be just to enable artifacts built by my Gradle build to be installed there, not third-party dependencies.

cheers Jon

The recommended way to declare the local Maven repository is mavenLocal(). You can install artifacts generated by a Gradle build into the local Maven repository with gradle install (if you have the “maven” plugin applied). Artifacts downloaded by Gradle will always go in its own cache.

Peter,

Thanks for the info.

Im using a non-standard location for the local Maven repo and so I found that mavenLocal() did not sniff it out. As your question was not answered I assume the sniffing code does not take M2_HOME/conf/settings.xml into account. http://issues.gradle.org/browse/GRADLE-1173

cheers Jon

This is a nifty feature to have. Say I have many Maven projects and want to slowly convert them then if there is a way to push dependencies into local repo without too much code Kunfu, this would be a blessing.

I think you are right in that the global settings file isn’t taken into account. However ~/.m2/settings.xml is taken into account. Maybe you can use this instead?

What do you expect to gain from this? Less downloading?

This is one.

But more than that if some projects are POM distributed then this is very much aggravated.

But more than that if some projects are POM distributed then this is very much aggravated.

I don’t understand what you are trying to say.

If u have a multi POM project with some distributed as POM. You convert some to Gradle. Other Maven dependencies down the line will not have dependencies in the local Maven catch.