Can I select which spring.xml file to use based on gradle task I build?

I have several tasks in my build.gradle file.
For some tasks, I would like to use the original spring.xml file
However, for another task, I would like to use a different file such as spring2.xml

What I am really trying to achieve is to have a gradle task that builds a WAR file where the webapp uses s3 file storage, and another gradle task build a WAR file where the webapp uses regular file storage.

What is the best way to do this ?

Hi,
For your purposes you can use Spring Profiles: Using Spring Profiles - CUBA Platform. Developer’s Manual

Thanks you Alexander. I used Spring Profiles and got it to work.

I created another file spring-s3.xml (in core):
(NOTE: the s3 file storage bean is only loaded for spring profile “s3”)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" profile="s3">

    <bean name="cuba_FileStorage" class="com.haulmont.addon.cubaaws.s3.AmazonS3FileStorage"/>

</beans>

and in app.properties, I adjusted the following line:

cuba.springContextConfig = +com/company/kairosmd/spring.xml com/company/kairosmd/spring-s3.xml

To add spring profile “s3” to my active spring profiles, I added the following parameter to my Java Options when running tomcat :

-Dspring.profiles.active=s3
1 Like