Repositories based on environment profiles


(Alvaro Abella) #1

Hi.

I’m new with gradle outside Android ecosystem, and now I’m with Spring Boot 2 application.
I’m reading this tutorial about profiles (https://www.credera.com/blog/technology-insights/java/gradle-profiles-for-multi-project-spring-boot-applications/) and I want to use something similar for repository configuration but with no lucky.

I would like to have something like this:

    if (project.hasProperty('dev')) {
        apply from: rootProject.file('gradle/profile_dev.gradle')
    } else {
        apply from: rootProject.file('gradle/profile_pro.gradle')
    }

on my build.gradle

profile_dev.gradle content is:

repositories {
    mavenCentral()
    jcenter() 
}

But i’m getting this error when I execute this ./gradlew -Pdev bootRun

Cannot resolve external dependency org.springframework.boot:spring-boot-gradle-plugin:2.0.2.RELEASE because no repositories are defined.
Required by:
    project :

Any idea or even better solution?
Thanks!