I'm trying to set the active spring profile when building a WAR file. I'm building the WAR file with gradle bootWar
I managed to find a solution that works for gradle bootRun -Pprofiles=prod
bootRun {
if (project.hasProperty('profiles')) {
environment SPRING_PROFILES_ACTIVE: profiles
}
}
But
bootWar {
if (project.hasProperty('profiles')) {
environment SPRING_PROFILES_ACTIVE: profiles
}
}
Gives me this error
Could not find method environment() for arguments [{SPRING_PROFILES_ACTIVE=staging}] on task ':bootWar' of type org.springframework.boot.gradle.tasks.bundling.BootWar.
How do I make it work for WAR files?