Multiple maven repositories in one gradle file
Asked Answered
F

2

332

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"
    }
}

In short, you have to do like this.

repositories {
  maven { url "http://maven.springframework.org/release" }
  maven { url "https://maven.fabric.io/public" }
}
Fowle answered 8/5, 2015 at 2:33 Comment(0)
P
653

As mentioned in gradleproject blog:

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'
}
Piezochemistry answered 8/5, 2015 at 2:33 Comment(4)
Is that the case regardless how closely related the URLs are?Garbanzo
Should we not expect artifactUrls to work? docs.gradle.org/current/dsl/…Hydrolysis
Can I use it in init.gradle?Cramfull
If i have sub-projects too, in that case, do i need to repositories with multiple url in configure(subprojects.findAll() ) {**} section too ?Lineolate
B
100

you have to do like this in your project level gradle file

allprojects {
    repositories {
        jcenter()
        maven { url "http://dl.appnext.com/" }
        maven { url "https://maven.google.com" }
    }
}
Bejewel answered 18/10, 2017 at 9:11 Comment(1)
Can I use it in init.gradle?Cramfull

© 2022 - 2024 — McMap. All rights reserved.