Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure maven local and remote repository in gradle build file?

Tags:

i want to use the maven local repository additionally to a maven remote one. I found the JIRA-Issue http://issues.gradle.org/browse/GRADLE-1173 for that, but adapting my gradle build file in that way some snapshot dependencies which are only available in the local maven repository are still not found. I get an error that the Snapshot-Dependency is not found.

Is it possible to have one local and one remote maven repository?

Here is the relevant part of my gradle build file:

apply plugin: 'maven'  repositories {      mavenLocal()      maven {         credentials {             username "myusername"             password "mypassword"         }         url "http://myremoterepository"     }  } 
like image 782
Cengiz Avatar asked Dec 05 '11 09:12

Cengiz


People also ask

Does Gradle use Maven local repository?

gradle - Gradle does not use the Maven Local Repository for a new dependency - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Does Gradle have local repository?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project. Gradle stores resolved dependencies in its own cache.


1 Answers

I also needed to do a similar setup with my project and I can verify your build.gradle setup works provided your Maven is setup correctly.

Gradle's mavenLocal() relies on the localRepository definition from the maven settings.xml file:

  <localRepository>USER_HOME\.m2\repository</localRepository> 

The settings.xml should be in either your M2_HOME/conf or your USER_HOME/.m2 directory. You should check:

  1. maven is installed correctly
  2. M2_HOME environment variable exists
  3. settings.xml has the correct localRepository defined..
like image 158
yunspace Avatar answered Sep 28 '22 09:09

yunspace