Dhiraj Agarwal
Dhiraj Agarwal

Reputation: 419

Exclude filter not working for filevault-package-maven-plugin

I have a content package with nodes I would like to exclude when this package is installed on AEM 6.5. The exclude configuration is defined in filter.xml (META-INF/vault/filter.xml).

Below is a representation of my filter.xml

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/amzn-biz">
        <exclude pattern="/apps/amzn-biz/i18n(.*)"/>
    </filter>
    <filter root="/apps/sling"/>
</workspaceFilter>

My pom.xml has below configuration

<!-- ====================================================================== -->
            <!-- V A U L T   P A C K A G E   P L U G I N S                              -->
            <!-- ====================================================================== -->
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <group>amzn-biz</group>
                    <acHandling>merge_preserve</acHandling>
                    <packageType>content</packageType>
                    <embeddeds>
                        <embedded>
                            <groupId>com.amazon.business</groupId>
                            <artifactId>amzn-biz-foundation.core</artifactId>
                            <target>/apps/amzn-biz/install</target>
                        </embedded>
                    </embeddeds>
                    <subPackages>
                        <subPackage>
                            <groupId>com.adobe.cq</groupId>
                            <artifactId>core.wcm.components.all</artifactId>
                            <filter>true</filter>
                        </subPackage>
                        <subPackage>
                            <groupId>com.adobe.cq</groupId>
                            <artifactId>core.wcm.components.examples</artifactId>
                            <filter>true</filter>
                        </subPackage>
                    </subPackages>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <verbose>true</verbose>
                    <failOnError>true</failOnError>
                </configuration>
            </plugin>

I have tried multiple things by changing my exclude patterns to ./i18n. but it has not worked for me.

I have also tried adding filterSource to filevault-package-maven-plugin configuration but then i get the error Project contains filter.xml in META-INF/vault but also specifies a filter source.

Upvotes: 4

Views: 4717

Answers (2)

Scott Yuan
Scott Yuan

Reputation: 21

The issue may be relating to <packageType>content</packageType> instead of filter.xml. This type cannot have sub-packages nor embedded bundles. If <embeddeds> and <subPackages> are needed for the project, use <packageType>mixed</packageType> will reduce chance of unexpected build and installation behaviors.

The list of package types and behaviors are as following:

  • application: Package consists pure application content (aka. /apps/*). Does not contain any subpackages nor OSGi configuration or bundles.
  • content: Package consists only of content and user defined configuration. Does not contain any subpackages nor OSGi configuration or bundles.
  • container: Package only contains sub packages and OSGi configuration and bundles.
  • mixed: Catch all type for a combination of the above.

More details can be found at http://jackrabbit.apache.org/filevault-package-maven-plugin/generate-metadata-mojo.html#packageType

Upvotes: 2

Alexander Berndt
Alexander Berndt

Reputation: 1728

You have to remove the nodes from the content package. You should not have any content in your content package, that is not explicitly covered by a filter-rule.

Your problem is weird backward-compatibility. At least in CQ5 were no filter-modes (mode="replace|merge|update") yet. In those days the rule was, that all content covered by a filter-rule is replaced. All other content is merged. When the filter-modes were introduced, they became non-intuitive but backward-compatible. In your case the i18n folder is merged.

Rule of thumb: A content package that is imported and exported again should be identical. (this would not be the case for you)

For more details see the table at https://jackrabbit.apache.org/filevault/filter.html#Usage_for_Import.2FInstallation for more information. For your i18n folder it says:

nodes which are ancestors of covered rules: deserialized from content package (for backwards compatibility reasons), nodes which are not ancestors of covered rules: not touched. One should not rely on this behaviour, i.e. all items in the content package should always be covered by some filter rule to make the behaviour more explicit.

Upvotes: 6

Related Questions