We use Springs PropertiesFactoryBean and PropertySourcesPlaceholderConfigurer to grab layered properties from the filesystem. Our POM.xml declares bar and then in our .property files we can reference the variable via a placeholder ${foo} ?Spring? magically replaces the value of ${foo} with the value declared in the POM.xml (I’m not 100% sure how this works)
How can we declare a property in build.gradle or gradle.properties or settings.gradle and have that brought into the placeholders in our Spring PropertyBean?
base.properties
foo=${foo}
root-context.xml
<bean id="configProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<set>
<value>classpath:config/env/base.properties</value>
<value>classpath:environment.properties</value>
</set>
</property>
</bean>
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>
pom.xml (snippet)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<properties>
<foo>bar</foo>
</properties>