Tiago Veloso
Tiago Veloso

Reputation: 8563

Gradle using two property files one for debug and release

I am trying to migrate an android project from maven to gradle.

In maven I have two profiles (dev and prod), dev profile uses a dev.properties file to set up some properties and prod uses prod.properties.

I want to be able to tell gradle to use dev.properties for debug build and prod.properties for release build.

More specifically all I need to do is rename the file to constants.properties

How can I achieve this?

Upvotes: 1

Views: 631

Answers (1)

David Levesque
David Levesque

Reputation: 22441

Assuming you already have a way to distinguish between dev vs prod, you can rename the file in Groovy with something like this:

def dev = true  // set to true or false
def propFile

if (dev) {
    propFile = file("dev.properties")
} else {
    propFile = file("prod.properties")
}
propFile.renameTo("constants.properties")

Upvotes: 3

Related Questions