AEM | How to add osgiconfig in archetype 26 and above !?
Veena Vikraman
Platform Architect at Merck and Adobe Experience League Community Advisor (AEM).
#AEMGyaan Time . For latest archetype supporting 6.5 , the OSGI Configs structure has been changed a bit. If you check your code base in AEM , you will see a node called osgiconfig under /apps/<projectname>
All your OSGI configurations are going to be added to this node and will be picked up from here .
As you might be aware , we should not be adding any OSGI Conifgurations directly to the Felix Console. It should always be added via config node of your project.
Now when using AEM archetype 26 and above ( which is mainly targeted for 6.5 and above) , the way the code and content is organized is bit different
mvn archetype:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=26
Once you create a project with these archetype and check your code base , you will see quite a lot of folder separations.
In addition to the ui.apps , core , all , ui.content, ui.frontend ; we have ui.config
Prior to this when the project is created we had fewer no of folder structure
All our configs were inside the ui.apps along with the rest of the components and templates. (config, config.author in this image is an example)
领英推荐
Now coming back to AEM Archetype 26 ; the content structure is different and the ui.apps has lesser folders than prior ones
So the questions comes back to "Where is osgi configs ? How do we add it to our codebase if we want to do it proper way ?"
Answer is simple , as you might have noticed before (or as I have mentioned before), there is some additional folders and one of those is ui.config
Going forward , you have to add all your OSGI Configs to this folder, which at the time of build will be compiled and added to the /apps/<projectname> as /apps/<projectname>/osgiconfig.
As you can see here , we have the config folders under osgiconfig inside ui.config of our project structure.
Any configuration , should be added with below naming convention as a JSON file
<configname>~<identifier>.cfg.json
for e.g I am adding a ServiceUserMapperImpl Amended config with below naming org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~learn-practice-aem.cfg.json
Please note the tilde (~) . The service name and your unique identifier should be separated with a ~ and the extension should be .cfg.json
Your JSON config should contain the config values in below format.
{
"<config-property-name>": "<config-property-value>",
.....
}
A sample JSON for the above said Service User Mapper is added below for reference
{
"user.default": "",
"user.mapping": [
"learn-practice-aem.core:readUser=[read-user]"
]
}
When this is added to your ui.config ; once you build your project and install it , these configurations will be available as /apps/<project-name>/osgiconfigs in your repository
Hope this helps some of you people. Since I was working in projects which had code base created using some older archetypes , I was not knowing this new structure. The first time I created a new project for 6.5+ project, via latest available archetype (non-cloud) is when I notice this. If you have any additional points to this or any corrections to this , please do let me know . Happy to correct my self ???
??
AEM Lead & Architect | 10+ Years in Digital Solutions & Web Content Management | Expert in Adobe Experience Manager
3 年Veena Vikraman , very useful information. However with archetype 25 or 24 as well we are doing the same.
Technologist | Building Customer Experiences | Content, Commerce
3 年Great insight! As most of the projects are due for migration to 6.5 this is very useful for developers and architects so as to not miss these seemingly small nuances. Thanks for sharing ????