<?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.0.3</version>
    </parent>

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

    <artifactId>accesscontroltool-oakindex-package</artifactId>
    <packaging>content-package</packaging>
    <name>Access Control Tool Package - Oak Index</name>
    <description>Package containing an oak index definition for 'rep:ACL' nodetypes. This speeds up the performance of the Access Control Tool.</description>

    <build>

        <plugins>
            <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>
                    <allowIndexDefinitions>true</allowIndexDefinitions>
                    <!-- overwrite (compare with https://issues.apache.org/jira/browse/JCRVLT-496) -->
                    <packageType>application</packageType>
                    <validatorsSettings>
                        <jackrabbit-packagetype>
                            <!-- https://issues.apache.org/jira/browse/JCRVLT-496 -->
                            <isDisabled>true</isDisabled>
                        </jackrabbit-packagetype>
                    </validatorsSettings>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-metadata-for-cloud</id>
                        <goals>
                            <goal>generate-metadata</goal>
                        </goals>
                        <configuration>
                            <classifier>cloud</classifier>
                        </configuration>
                    </execution>
                    <execution>
                        <id>package-for-cloud</id>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <classifier>cloud</classifier>
                            <!-- due to https://issues.apache.org/jira/browse/JCRVLT-498 -->
                            <workDirectory>${project.build.directory}/vault-work-cloud</workDirectory>
                        </configuration>
                    </execution>
                </executions>
           </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>
            
            <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.10</version>
				<executions>
					<execution>
						<!-- integrate the hook from https://github.com/code-distillery/filevault-oak-reindex-hook to only reindex if really necessary -->
						<id>copy-reindex-hook-into-package</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>net.distilledcode</groupId>
									<artifactId>filevault-oak-reindex-hook</artifactId>
									<version>1.0.2</version>
								</artifactItem>
							</artifactItems>
							<outputDirectory>${project.build.directory}/vault-work/META-INF/vault/hooks</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>
											org.apache.maven.plugins
										</groupId>
										<artifactId>
											maven-dependency-plugin
										</artifactId>
										<versionRange>
											[2.10,)
										</versionRange>
										<goals>
											<goal>copy</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore />
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
    </build>
    <profiles>
        <profile>
            <id>autoInstallOakIndexPackage</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>autoInstallOakIndexPackagePublish</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>
