Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple maven repositories in one gradle file

So my problem is how to add multiple maven repositories to one gradle file.

This DOESN’T work:

repositories {     mavenCentral()     maven {         url "http://maven.springframework.org/release"         url "http://maven.restlet.org"     } } 
like image 392
AZ_ Avatar asked May 08 '15 02:05

AZ_


People also ask

Can Gradle use Maven repositories?

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.

What is mavenCentral () in Gradle?

jcenter() and mavenCentral() is a repository for the Gradle plugin in Android Studio. Earlier versions of Android Studio used mavenCentral(), and after some time, it switched to jcenter.

Can you mix Maven and Gradle?

Short answer: yes. There's no conflict between having two independent build scripts for the same project, one in Maven and one in Gradle.


1 Answers

In short you have to do like this

repositories {   maven { url "http://maven.springframework.org/release" }   maven { url "https://maven.fabric.io/public" } } 

Detail:

You need to specify each maven URL in its own curly braces. Here is what I got working with skeleton dependencies for the web services project I’m going to build up:

apply plugin: 'java'  sourceCompatibility = 1.7 version = '1.0'  repositories {   maven { url "http://maven.springframework.org/release" }   maven { url "http://maven.restlet.org" }   mavenCentral() }  dependencies {   compile group:'org.restlet.jee', name:'org.restlet', version:'2.1.1'   compile group:'org.restlet.jee', name:'org.restlet.ext.servlet',version.1.1'   compile group:'org.springframework', name:'spring-web', version:'3.2.1.RELEASE'   compile group:'org.slf4j', name:'slf4j-api', version:'1.7.2'   compile group:'ch.qos.logback', name:'logback-core', version:'1.0.9'   testCompile group:'junit', name:'junit', version:'4.11' } 

Blog

like image 197
AZ_ Avatar answered Sep 22 '22 22:09

AZ_