[GRADLE-1173] More easily referenced Maven local repo cache Created: 13/Oct/10  Updated: 29/Jul/14  Resolved: 30/Dec/10

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 0.9.1

Type: New Feature
Reporter: Steve Ebersole Assignee: Hans Dockter
Resolution: Fixed Votes: 0


 Description   

Currently it is customary to include the user's local maven repository cache as a dependency repository for "downloading" artifacts. The standard way seems to be:

repositories {
    ...
    mavenRepo urls: "file://" + System.getProperty('user.home') + "/.m2/repository/"
}

The problem with that is that users are free to specify an alternate cache directory, the standard way being via settings.xml.

I have developed some code y'all are free to use that sniffs out that situation. In my build I simply add that location as a repository. But I think the best generic solution is to make this available as a method mush like mavenCentral() is currently. Then user could say:

repositories {
    ...
    mavenLocal()
}

mavenCache() was another term suggested.

The "sniffing" code is available at http://github.com/hibernate/hibernate-core/blob/master/buildSrc/src/main/java/org/hibernate/build/gradle/maven/LocalMavenRepoSniffer.java



 Comments   
Comment by Adam Murdoch [ 30/Dec/10 ]

I've added a mavenLocal() method, which uses your code to locate the cache. Thanks for figuring this out.

Comment by Peter Niederwieser [ 06/Jan/11 ]

Does the sniffing code consider the global settings file (maven_home/conf/settings.xml) as well?

Comment by Joel Byrnes [ 12/Feb/13 ]

Thanks for this feature.

Please also update the documentation, http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html seems like the right place. This is a fairly basic option for those used to maven, where things will break unexpectedly for snapshots built locally.

A google search for "site:gradle.org mavenLocal()" indicates that this method is only referenced in issues or forums, or buried in the API at http://www.gradle.org/docs/current/groovydoc/org/gradle/api/artifacts/dsl/RepositoryHandler.html.

Comment by Adam Murdoch [ 16/Feb/13 ]

@Joel, could you create a separate jira issue for the documentation updates? Thanks.

Generated at Wed Jun 30 11:48:50 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.