<?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>2.3.2</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>Core package of the AC Tool containing the bundle, system user and ACLs for it.</description>
    
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>accesscontroltool-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-hook-into-package</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <!-- See http://sling.apache.org/documentation/bundles/installer-provider-installhook.html -->
                                <artifactItem>
                                    <groupId>org.apache.sling</groupId>
                                    <artifactId>org.apache.sling.installer.provider.installhook</artifactId>
                                    <version>1.0.4</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/vault-work/META-INF/vault/hooks</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>        
        
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <configuration>
                    <group>Netcentric</group>
                    <filterSource>src/main/META-INF/vault/filter.xml</filterSource>
                    <properties>
                        <acHandling>merge_preserve</acHandling>
                        <!-- 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>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>accesscontroltool-bundle</artifactId>
                        </embedded>
                        <embedded>
                            <groupId>org.yaml</groupId>
                            <artifactId>snakeyaml</artifactId>
                        </embedded>
                    </embeddeds>
                    <embeddedTarget>/apps/netcentric/actool/install</embeddedTarget>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
                <configuration>
                    <targetURL>http://${crx.host}:${crx.port}/crx/packmgr/service.jsp</targetURL>
                </configuration>
            </plugin>
            
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>autoInstallPackage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-content-package</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>autoInstallPackagePublish</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>install-content-package-publish</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                                <configuration>
                                    <targetURL>http://${publish.crx.host}:${publish.crx.port}/crx/packmgr/service.jsp</targetURL>
                                    <username>${publish.crx.username}</username>
                                    <password>${publish.crx.password}</password>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
