Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change location of local maven repository in gradle

Tags:

maven

gradle

publishToMavenLocal always publishes to either ~/.m2 or the path set for <LocalRepository> tag in ~/.m2/settings.xml. However when I set the system property maven.repo.local it is ignored. Is there a way to override the location of the local maven repository when publishing using gradle publishToMavenLocal, other than settings.xml (I am looking for either project property or system property or environment variable).

Here is what I tried gradle -Dmaven.repo.local=/home/skgupta/myrepo build pTML

Please help

like image 240
Sundeep Gupta Avatar asked Feb 11 '15 12:02

Sundeep Gupta


People also ask

Does Gradle use Maven local repository?

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

What is mavenLocal () in Gradle?

repositories { mavenLocal() } Gradle uses the same logic as Maven to identify the location of your local Maven cache. If a local repository location is defined in a settings. xml , this location will be used.

Where is .m2 for Gradle?

Gradle looks into '~/. m2/settings. xml' for information where the local Maven repository is located.


1 Answers

Your -Dmaven.repo.local approach is working on my Gradle v4.8.1, here is the rundown:

gradle --stop
export M2_HOME=/tmp/other_em_two
export M2_REPO=$M2_HOME/repository
mkdir -p $M2_REPO
tree $M2_REPO
gradle -Dmaven.repo.local=$M2_REPO pTML
tree $M2_REPO

Will show published files.

like image 102
Mashimom Avatar answered Sep 29 '22 12:09

Mashimom