How to enable merge mode for the packages in Adobe Experience Manager(AEM)
By default the packages build in AEM package manager is enabled with mode "overwrite", this will overwrite the target folder upon installing the package - the local changes under that folder will be lost.
This post explains the approach to enable the merge mode for the packages, this will help us to merge the package content with the repository content.
Create the package with required path and download to local file system
Unzip the package zip file on your computer - jar -xvf test_mode-1.0.zip META-INF/vault/filter.xml
Open the file META-INF/vault/filter.xml in a text editor.
Add mode="merge" to the <filter ...> tag, the merge mode should be added to all the filters defined for example:
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="xxxxx" mode="merge" >
<exclude pattern="xxxxx" />
</filter>
<filter root="xxxx" mode="merge"/>
</workspaceFilter>
e.g
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/content/we-retail/us/en/products/women" mode="merge" />
</workspaceFilter>
Available Filter Modes:
"replace" - This is the normal behavior. Existing content is replaced completely by the imported content, i.e. is overridden or deleted accordingly.
"merge" - Existing content is not modified, i.e. only new content is added and none is deleted or modified.
"update" - Existing content is updated, new content is added and none is deleted.
The default filter mode is "replace"
Re-zip the modified package contents so it includes the change - jar -uvf test_mode-1.0.zip META-INF/vault/filter.xml
Upload the modified package to target server - this will make sure the target server changes are not overwritten.