<?xml version="1.0" encoding="UTF-8"?>
<!--
    (C) Copyright 2015 Netcentric AG.

    All rights reserved. This program and the accompanying materials
    are made available under the terms of the Eclipse Public License v1.0
    which accompanies this distribution, and is available at
    http://www.eclipse.org/legal/epl-v10.html
-->
<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>biz.netcentric.cq.tools.accesscontroltool</groupId>
        <artifactId>accesscontroltool</artifactId>
        <version>3.4.0</version>
    </parent>

    <!-- ====================================================================== -->
    <!-- P R O J E C T D E S C R I P T I O N -->
    <!-- ====================================================================== -->

    <artifactId>accesscontroltool-package</artifactId>
    <packaging>content-package</packaging>
    <name>Access Control Tool Package</name>
    <description>Container package of the AC Tool containing the bundle, config, apps and content package.</description>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>accesscontroltool-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>accesscontroltool-startuphook-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>accesscontroltool-apps-package</artifactId>
            <version>${project.version}</version>
            <type>content-package</type>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>accesscontroltool-content-package</artifactId>
            <version>${project.version}</version>
            <type>content-package</type>
        </dependency>
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>aem-sdk-api</artifactId>
            <version>2021.5.5343.20210524T070738Z-210527</version>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <!-- see https://github.com/apache/felix/tree/trunk/tools/osgicheck-maven-plugin -->
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>osgicheck-maven-plugin</artifactId>
                    <version>0.1.0</version>
                    <executions>
                        <execution>
                            <id>check-bundle</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- optionally generate two packages: one for cloud (classifier "cloud") and one for classic (no classifier) -->
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <configuration>
                    <embeddedTarget>/apps/netcentric/actool/install</embeddedTarget>
                    <packageType>container</packageType>
                    <!-- all sub packages have been validated already -->
                    <skipSubPackageValidation>true</skipSubPackageValidation>
                </configuration>
                <executions>
                    <execution>
                        <id>default-generate-metadata</id>
                        <configuration>
                            <properties>
                                <!-- install the two bundles and service user config synchronously in order to be callable from within 
                                      same complete package (if yaml file containing package declares the dependency to it) -->
                                <installPathRegex>/apps/netcentric/actool/(config|install)/.*</installPathRegex>
                                <waitForOsgiEventsQuietInSec>5</waitForOsgiEventsQuietInSec>
                            </properties>
                            <embeddeds>
                                <embedded>
                                    <artifactId>accesscontroltool-bundle</artifactId>
                                </embedded>
                                <embedded>
                                    <artifactId>accesscontroltool-startuphook-bundle</artifactId>
                                    <target>/apps/netcentric/actool/install/27</target>
                                </embedded>
                            </embeddeds>
                            <subPackages>
                                <subPackage>
                                    <artifactId>accesscontroltool-apps-package</artifactId>
                                </subPackage>
                                <subPackage>
                                    <artifactId>accesscontroltool-content-package</artifactId>
                                </subPackage>
                            </subPackages>
                            <!-- See http://sling.apache.org/documentation/bundles/installer-provider-installhook.html -->
                            <installHooks>org.apache.sling:org.apache.sling.installer.provider.installhook:1.1.0</installHooks>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-analyze-classes</id>
                        <phase>invalid</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.adobe.aem</groupId>
                <artifactId>aemanalyser-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>cloud</id>
            <!-- automatically active on CI -->
            <activation>
                <property>
                    <name>env.CI</name>
                </property>
            </activation>
            <properties>
                <!-- install package with "cloud" classifier to AEM -->
                <contentPackageFile>${project.build.directory}/${project.build.finalName}-cloud.zip</contentPackageFile>
            </properties>
            <build>
                <plugins>
                     <!-- for "cloud" package use repoinit instead of actool-content-package -->
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-cloud-package-resources</id>
                                <!-- here the phase you need -->
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/vault-work-cloud/jcr_root</outputDirectory>
                                    <resources>
                                      <resource>
                                        <directory>src/main/jcr_root-cloud</directory>
                                        <filtering>false</filtering>
                                      </resource>
                                    </resources>
                                </configuration> 
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- optionally generate two packages: one for cloud (classifier "cloud") and one for classic (no classifier) -->
                        <groupId>org.apache.jackrabbit</groupId>
                        <artifactId>filevault-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cloud-generate-metadata</id>
                                <goals>
                                    <goal>generate-metadata</goal>
                                </goals>
                                <configuration>
                                    <!-- everything via embed, no subpackages, no accesscontroltool-content-package -->
                                    <embeddeds>
                                        <embedded>
                                            <artifactId>accesscontroltool-bundle</artifactId>
                                        </embedded>
                                        <embedded>
                                            <artifactId>accesscontroltool-apps-package</artifactId>
                                        </embedded>
                                        <embedded>
                                            <artifactId>accesscontroltool-startuphook-bundle</artifactId>
                                            <target>/apps/netcentric/actool/install/27</target>
                                        </embedded>
                                    </embeddeds>
                                    <classifier>cloud</classifier>
                                </configuration>
                            </execution>
                            <execution>
                                <id>cloud-package</id>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                                <configuration>
                                    <classifier>cloud</classifier>
                                    <failOnDuplicateEntries>false</failOnDuplicateEntries>
                                </configuration>
                            </execution>
                            <execution>
                                <id>default-validate-package</id>
                                <configuration>
                                    <!-- validate both generated packages in one execution -->
                                    <classifier>cloud</classifier>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.adobe.aem</groupId>
                        <artifactId>aemanalyser-maven-plugin</artifactId>
                        <configuration>
                            <classifier>cloud</classifier>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
