I have a Spring boot application which is managed by Gradle.
What is done so far:
- Created
application.yaml,application-dev.yaml, andapplication-qa.yamlfiles - Mentioned
spring: profiles: active: devinapplication.yaml(default profile should bedevif none is mentioned)
What need to be done:
- Need to build
warwith profile mentioned or passed while building. Example, for QA build,spring: profiles: active:should have valueqa, so that it can pick-upapplication-qa.yamlproperties. - If no profile is passed, then by default
devprofile should be selected
What is tried so far:
Added
@activeProfiles@inspring: profiles: active: @activeProfiles@inapplication.yamland added below snippet inbuild.gradle:processResources { filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [ activeProfiles: activeProfiles ] }And fired following command to build the
war-gradlew clean build -PactiveProfiles=qa, and it just did right job forwarfile. But now issue with this approach is, how to provide default value foractiveProfileswhile running the project from IDE (I usually prefer to runmainclass from IntelliJ)?
I am also not sure if this is the correct approach or is there any other approach to achieve this task. I have already done all these stuff with Maven, and with ease, but I am new to Gradle, and it's project requirement to use Gradle.