<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
        <groupId>com.exadel.etoolbox</groupId>
        <artifactId>etoolbox-authoring-kit</artifactId>
        <version>2.5.3</version>
    </parent>

    <artifactId>etoolbox-authoring-kit-all</artifactId>

    <name>Exadel Toolbox Authoring Kit - Cumulative Package</name>
    <description>All-in-one content package of Exadel Toolbox Authoring Kit</description>

    <packaging>content-package</packaging>

    <build>
        <finalName>${project.parent.artifactId}.all-${project.version}</finalName>
        <resources>
            <resource>
                <directory>src/main/content/jcr_root</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/.vlt</exclude>
                    <exclude>**/.vltignore</exclude>
                    <exclude>**/.keep</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>${basedir}/src/main/content/META-INF</directory>
                <targetPath>../vault-work/META-INF</targetPath>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
                <configuration>
                    <properties>
                        <description>${project.description}</description>
                    </properties>
                    <filters>
                        <filter>
                            <root>/etc/packages/${project.groupId}/${project.parent.artifactId}</root>
                            <excludes>
                                <exclude>/etc/packages/${project.groupId}/${project.parent.artifactId}/${project.parent.artifactId}.all-${project.version}.zip</exclude>
                                <exclude>/etc/packages/${project.groupId}/${project.parent.artifactId}/.snapshot/${project.parent.artifactId}.all-${project.version}.zip</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>clean-install-folder</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
                            <filesets>
                                <fileset>
                                    <directory>${basedir}/src/main/content/jcr_root/etc/packages/${project.groupId}</directory>
                                    <includes>
                                        <include>**</include>
                                    </includes>
                                    <excludes>
                                        <exclude>${project.parent.artifactId}/.snapshot</exclude>
                                        <exclude>${project.parent.artifactId}/.snapshot/.keep</exclude>
                                    </excludes>
                                </fileset>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-nested-packages</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/src/main/content/jcr_root/etc/packages/${project.groupId}/${project.parent.artifactId}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.parent.basedir}/ui.apps/target</directory>
                                    <includes>
                                        <include>${project.parent.artifactId}-ui.apps-${project.version}.zip</include>
                                    </includes>
                                </resource>
                                <resource>
                                    <directory>${project.parent.basedir}/ui.content/target</directory>
                                    <includes>
                                        <include>${project.parent.artifactId}-ui.content-${project.version}.zip</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>autoInstallPackage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
