Expand my Community achievements bar.

Dynamic property value on deployment

Avatar

Level 4

I'm looking to populate a property within a node in my repo and I would like the value of the property to be different for each of my environments (dev, staging, and live). At the moment I am populating the property with a value in the .content.value file within my Maven project that is relative to the node. I'm wondering if anyone could offer some advice on how to set this property with a different value upon deployment of the project. So, for example, when I deploy to the live server, the property has a different value than when I deploy to the staging server.

I've attempted a pretty convoluted way of solving this by creating a service that uses a resource resolver to get the resource from the JCR and add the property. I have a config file and run time configuration that I use to set the value of the property via an OSGI configuration for the service. This doesn't work because the service runs before the node is created in my apps module.

Anyone got any ideas?

1 Reply

Avatar

Employee Advisor

Hi,

if you have the data already during build time, you could create a service, and provide the configuration for this service based on the runmode (prod, dev, stage, etc.). Please see [1] for setting the runmodes and [2] for an example how to use them.

 

[1] https://docs.adobe.com/docs/en/aem/6-2/deploy/configuring/configure-runmodes.html
[2] http://www.computepatterns.com/43/osgi-component-in-aem-that-is-active-only-in-specific-run-mode-say...