1// ---- 2// How to use Profiles with -P arguments 3// ---- 4// 5// Run gradle tasks with the -P argument to utilize a profile. 6// 7 8def prodProfiles = 'prod' 9def stagingProfiles = 'staging' 10def defaultProfiles = 'default' 11def propertyDrivenProfiles 12 13if (project.hasProperty('prod')) { 14 // Used for production environment 15 propertyDrivenProfiles = prodProfiles 16 apply from: rootProject.file('gradle/profile_prod.gradle'); 17 18} else if (project.hasProperty('staging')) { 19 // Used for local development 20 propertyDrivenProfiles = stagingProfiles 21 apply from: rootProject.file('gradle/profile_staging.gradle'); 22 23} else { 24 // Default when no profile property is specified, used for testing 25 propertyDrivenProfiles = defaultProfiles 26 apply from: rootProject.file('gradle/profile_default.gradle'); 27} 28println 'Using profile: "' + propertyDrivenProfiles + '" for ' + project.getName() 29 30