<?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~ Copyright 2016 Adobe
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<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">
    <modelVersion>4.0.0</modelVersion>

    <!-- ====================================================================== -->
    <!-- P A R E N T  P R O J E C T  D E S C R I P T I O N                      -->
    <!-- ====================================================================== -->
    <parent>
        <groupId>com.adobe.cq</groupId>
        <artifactId>core.email.components.parent</artifactId>
        <version>1.2.2</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>

    <!-- ====================================================================== -->
    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
    <!-- ====================================================================== -->
    <artifactId>core.email.components.content</artifactId>
    <version>1.2.2</version>
    <packaging>content-package</packaging>
    <name>Adobe Experience Manager Core Email Components Content Package</name>

    <!-- ====================================================================== -->
    <!-- B U I L D   D E F I N I T I O N                                        -->
    <!-- ====================================================================== -->
    <build>
        <sourceDirectory>src/content/jcr_root</sourceDirectory>
        <resources>
            <!-- define the resources that will go into the package -->
            <resource>
                <!--
                    we want to keep some of the META-INF files and not configure
                    everything in the plugin.
                -->
                <directory>${basedir}/src/content/META-INF/vault/definition</directory>
                <targetPath>../vault-work/META-INF/vault/definition</targetPath>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <filters>
                        <filter>
                            <root>/apps/core/email/components</root>
                        </filter>
                    </filters>
                    <packageType>application</packageType>
                    <dependencies>
                        <dependency>
                            <group>day/cq60/product</group>
                            <name>cq-platform-content</name>
                            <version>[1.3.248,)</version>
                        </dependency>
                    </dependencies>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>htl-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>validate-htl-scripts</id>
                        <goals>
                            <goal>validate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <generateJavaClasses>true</generateJavaClasses>
                            <generatedJavaClassesPrefix>org.apache.sling.scripting.sightly
                            </generatedJavaClassesPrefix>
                            <allowedExpressionOptions>
                                <allowedExpressionOption>cssClassName</allowedExpressionOption>
                                <allowedExpressionOption>decoration</allowedExpressionOption>
                                <allowedExpressionOption>decorationTagName</allowedExpressionOption>
                                <allowedExpressionOption>wcmmode</allowedExpressionOption>
                            </allowedExpressionOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${node.version}</nodeVersion>
                            <npmVersion>${npm.version}</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>lint</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run lint</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>sync pom version to package.json</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run sync-pom-version</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <configuration>
                    <excludes combine.children="append">
                        <!-- Ignore lint-files -->
                        <exclude>**/*.eslintrc</exclude>
                        <exclude>**/*.editorconfig</exclude>
                        <exclude>**/*.stylelintrc.yaml</exclude>
                        <exclude>**/*.eslintignore</exclude>
                        <!-- Ignore Node and npm -->
                        <exclude>**/node/**</exclude>
                        <exclude>**/node_modules/**</exclude>
                        <!-- Ignore generated datalayer clientlib -->
                        <exclude>**/core.email.components.commons.datalayer.v1/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- ====================================================================== -->
    <!-- P R O F I L E S                                                        -->
    <!-- ====================================================================== -->
    <profiles>
        <profile>
            <id>autoInstallPackage</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-package</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <targetURL>
                                        http://${aem.host}:${aem.port}${aem.contextPath}/crx/packmgr/service.jsp
                                    </targetURL>
                                    <failOnError>true</failOnError>
                                    <packageFile>${contentPackageFile}</packageFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>autoInstallPackagePublish</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-package-publish</id>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <targetURL>
                                        http://${aem.publish.host}:${aem.publish.port}${aem.contextPath}/crx/packmgr/service.jsp
                                    </targetURL>
                                    <failOnError>true</failOnError>
                                    <packageFile>${contentPackageFile}</packageFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cloud</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <contentPackageFile>
                    ${project.build.directory}/${project.build.finalName}-cloud.zip
                </contentPackageFile>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/jcr_root/libs
                                    </outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/content/jcr_root/apps
                                            </directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <tasks>
                                        <replace file="target/jcr_root/libs/core/email/components/button/v1/button/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/container/v1/container/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/button/v1/button/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/contentfragment/v1/contentfragment/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/experiencefragment/v1/experiencefragment/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/image/v1/image/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/segmentation/v1/segmentation/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/teaser/v1/teaser/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/text/v1/text/.content.xml" token=".core-email" value="Core E-Mail" />
                                        <replace file="target/jcr_root/libs/core/email/components/title/v1/title/.content.xml" token=".core-email" value="Core E-Mail" />
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.jackrabbit</groupId>
                        <artifactId>filevault-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-metadata-cloud</id>
                                <goals>
                                    <goal>generate-metadata</goal>
                                </goals>
                                <configuration>
                                    <filters>
                                        <filter>
                                            <root>/libs/core/email/components</root>
                                        </filter>
                                    </filters>
                                    <classifier>cloud</classifier>
                                </configuration>
                            </execution>
                            <execution>
                                <id>package-cloud</id>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                                <configuration>
                                    <jcrRootSourceDirectory>${project.build.directory}/jcr_root
                                    </jcrRootSourceDirectory>
                                    <classifier>cloud</classifier>
                                    <workDirectory>${project.build.directory}/vault-work-cloud
                                    </workDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <!-- ====================================================================== -->
    <!-- D E P E N D E N C I E S                                                -->
    <!-- ====================================================================== -->
    <dependencies>
        <!-- AEM Core Components Bundle -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>core.email.components.core</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>


        <!-- HTL dependencies needed for the HTL Maven Plugin source code generation -->
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.sightly.compiler</artifactId>
            <version>1.2.4-1.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.scripting.sightly.runtime</artifactId>
            <version>1.2.0-1.4.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- AEM APIs -->
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
