Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: Load property file dependent on profile

Tags:

gradle

I want to write a gradle build script, which works in different environments (development, live). In each environment I have to load different property sets (target directories, databases, etc.).

Is there a gradle way to read a property file dependent on the environment or a profile?

like image 470
Lorim Avatar asked Sep 04 '14 20:09

Lorim


2 Answers

You may want to check out the Gradle Properties Plugin.

Include plugin:

plugins {
  id 'net.saliman.properties' version '1.4.2'
}

Create property files:

gradle-dev.properties

or

gradle-prod.properties

Call gradle:

gradle myTask -PenvironmentName=dev
gradle myTask -PenvironmentName=prod
like image 161
Mark Vieira Avatar answered Sep 19 '22 07:09

Mark Vieira


Also have a look at gradle's equivalent of maven's profiles.

like image 33
Opal Avatar answered Sep 21 '22 07:09

Opal