I am using IntelliJ and I know how to use Profiles in Spring Boot to specify which application.properties file to use.
But when I create WAR file with Gradle all of these application.properties file are included into WAR. Is it possible to somehow create WAR File that will have only needed application.properties files.
Like only
- application.properties
- application-profile1.properties
And not all of them
- application.properties
- application-profile1.properties
- application-profile2.properties
- application-profile3.properties
I have seen that in Gradle I can use
tasks.jar {
exclude('application-profile1.properties')
I have found an example saying to use
gradle --build-file=build1.gradle
So in IntelliJ I can Edit Run Configuration like this
jar --build-file=build1.gradle
and it will work
But if I do exactly the same for WAR then file is not excluded
tasks.war {
exclude('application-profile1.properties')
war --build-file=build1.gradle
It seems that this is because for war syntax is different
tasks.war {
rootSpec.exclude('**/application-profile1.properties')
So now I have multiple build1.gradle files in which I am excluding non related application.properties. And because of that I have multiple Run Configuration to run each of these files. But this doesn’t look like the optimal solution. I think it woulg be better to just have single build.gradle with some logic inside it. And single Run Configuration with some parameter. But at this point I am not sure how to do that. I usua;;y work with Maven adn I know hat Gradle support some logic syntax.
1