<?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>
    <!-- ====================================================================== -->
    <!-- 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.acs</groupId>
        <artifactId>acs-aem-commons</artifactId>
        <version>4.5.2</version>
    </parent>

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

    <artifactId>acs-aem-commons-ui.content</artifactId>
    <name>ACS AEM Commons UI.Content Package</name>
    <packaging>content-package</packaging>

    <build>
        <resources>
            <resource>
                <directory>src/main/content/jcr_root</directory>
                <excludes>
                    <exclude>**/.vlt</exclude>
                    <exclude>**/.vltignore</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/content/META-INF/vault/definition</directory>
                <targetPath>../vault-work/META-INF/vault/definition</targetPath>
            </resource>
            <resource>
                <directory>src/main/content/META-INF/vault</directory>
                <includes>
                    <include>nodetypes.cnd</include>
                    <include>privileges.xml</include>
                </includes>
                <targetPath>../vault-work/META-INF/vault</targetPath>
            </resource>
            <resource>
                <directory>src/main/resources/META-INF</directory>
                <targetPath>../vault-work/META-INF</targetPath>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>${maven.multiModuleProjectDirectory}/src/test/resources</directory>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <includeEmptyDirs>true</includeEmptyDirs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.day.jcr.vault</groupId>
                <artifactId>content-package-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <group>adobe/consulting</group>
                    <filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>
                    <properties>
                        <description>ACS AEM Commons content package containing content and configuration.</description>
                        <acHandling>merge</acHandling>
                    </properties>
                    <dependencies>
                        <dependency>
                            <group>adobe/consulting</group>
                            <name>acs-aem-commons-ui.apps</name>
                            <version>${project.version}</version>
                        </dependency>
                    </dependencies>
                    <targetURL>http://${crx.host}:${crx.port}${crx.contextRoot}/crx/packmgr/service.jsp</targetURL>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.adamcin.oakpal</groupId>
                <artifactId>oakpal-maven-plugin</artifactId>
                <configuration>
                    <deferBuildFailure>true</deferBuildFailure>
                    <checklists>
                        <checklist>acs-internal</checklist>
                    </checklists>
                    <!-- use mvn oakpal:webster -Dwebster.repositoryHome=/path/to/crx-quickstart/repository to update
                    nodetypes.cnd and privileges.xml in the package -->

                    <checks>
                        <!-- Enforce separation of content and code (CONTENT ONLY) -->
                        <check>
                            <name>basic/paths</name>
                            <config>
                                <rules>
                                    <rule>
                                        <pattern>/apps(/.*)?</pattern>
                                        <type>deny</type>
                                    </rule>
                                </rules>
                                <denyAllDeletes>true</denyAllDeletes>
                            </config>
                        </check>
                        <!-- check that rep:policy nodes are actually created by the package -->
                        <check>
                            <name>check-expected-policy-paths</name>
                            <template>basic/expectPaths</template>
                            <config>
                                <severity>minor</severity>
                                <expectedPaths>
                                    <path>/oak:index/rep:policy</path>
                                    <path>/conf/rep:policy</path>
                                    <path>/content/rep:policy</path>
                                    <path>/content/dam/rep:policy</path>
                                    <path>/etc/rep:policy</path>
                                    <path>/etc/acs-commons/bulk-workflow-manager/rep:policy</path>
                                    <path>/etc/acs-commons/notifications/rep:policy</path>
                                    <path>/etc/acs-commons/redirect-maps/rep:policy</path>
                                    <path>/etc/cloudservices/dtm/rep:policy</path>
                                    <path>/etc/cloudservices/sharethis/rep:policy</path>
                                    <path>/etc/cloudservices/typekit/rep:policy</path>
                                    <path>/etc/notification/email/rep:policy</path>
                                    <path>/etc/workflow/instances/rep:policy</path>
                                    <path>/home/groups/rep:policy</path>
                                    <path>/home/users/rep:policy</path>
                                    <path>/var/workflow/instances/rep:policy</path>
                                    <path>/var/acs-commons/rep:policy</path>
                                    <path>/var/acs-commons/httpcache/rep:policy</path>
                                    <path>/var/acs-commons/mcp/rep:policy</path>
                                    <path>/var/acs-commons/on-deploy-scripts-status/rep:policy</path>
                                </expectedPaths>
                            </config>
                        </check>
                        <check>
                            <name>verify-acls-on-root</name>
                            <template>basic/expectAces</template>
                            <!-- since the root rep:policy node will obviously exist regardless, we should be more
                            specific for these acl entries -->
                            <config>
                                <expectedAces>
                                    <expectedAce>
                                        principal=acs-commons-ensure-oak-index-service
                                        ;type=allow;path=/;privileges=jcr:read,rep:write,rep:indexDefinitionManagement
                                    </expectedAce>
                                    <expectedAce>
                                        principal=acs-commons-dispatcher-flush-service
                                        ;type=allow;path=/;privileges=jcr:read,crx:replicate,jcr:removeNode
                                    </expectedAce>
                                    <expectedAce>
                                        principal=acs-commons-package-replication-status-event-service
                                        ;type=allow;path=/;privileges=jcr:read,rep:write,jcr:readAccessControl,jcr:modifyAccessControl
                                    </expectedAce>
                                    <expectedAce>
                                        principal=acs-commons-ensure-service-user-service
                                        ;type=allow;path=/;privileges=jcr:read,rep:write,jcr:readAccessControl,jcr:modifyAccessControl
                                    </expectedAce>
                                    <expectedAce>
                                        principal=acs-commons-on-deploy-scripts-service
                                        ;type=allow;path=/;privileges=jcr:read
                                    </expectedAce>
                                </expectedAces>
                            </config>
                        </check>
                    </checks>

                    <!-- assume that we are installing into an instance where utility pages and configs have already
                    been created for prior versions -->
                    <forcedRoots>
                        <forcedRoot>
                            <path>/etc/acs-commons/bulk-workflow-manager/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/dispatcher-flush/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/exporters/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/instant-package/jcr:content/config/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/lists/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/notifications/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/packagers/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/qr-code/jcr:content/config/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/acs-commons/redirect-maps/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/cloudservices/dtm/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/cloudservices/sharethis/default</path>
                        </forcedRoot>
                        <forcedRoot>
                            <path>/etc/cloudservices/typekit/default</path>
                        </forcedRoot>
                    </forcedRoots>

                    <websterTargets>
                        <nodetypes />
                        <privileges />
                    </websterTargets>
                </configuration>
                <executions>
                    <execution>
                        <id>oakpal-scan</id>
                        <goals>
                            <goal>scan</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>oakpal-scan-content-class-aem65</id>
                        <goals>
                            <goal>scan</goal>
                        </goals>
                        <configuration>
                            <summaryFile>${project.build.directory}/oakpal-plugin/reports/content-class-aem65.json</summaryFile>
                            <checklists>
                                <checklist>content-class-aem65</checklist>
                            </checklists>
                        </configuration>
                    </execution>
                    <execution>
                        <id>oakpal-scan-content-class-aem64</id>
                        <goals>
                            <goal>scan</goal>
                        </goals>
                        <configuration>
                            <summaryFile>${project.build.directory}/oakpal-plugin/reports/content-class-aem64.json</summaryFile>
                            <checklists>
                                <checklist>content-class-aem64</checklist>
                            </checklists>
                        </configuration>
                    </execution>
                    <execution>
                        <id>oakpal-scan-min</id>
                        <goals>
                            <goal>scan-many</goal>
                        </goals>
                        <configuration>
                            <summaryFile>${project.build.directory}/oakpal-plugin/reports/oakpal-summary-min.json</summaryFile>
                            <scanArtifacts>
                                <artifact>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <classifier>min</classifier>
                                    <type>zip</type>
                                </artifact>
                            </scanArtifacts>
                        </configuration>
                    </execution>
                    <execution>
                        <id>oakpal-verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <summaryFiles>
                                <summaryFile>${project.build.directory}/oakpal-plugin/reports/content-class-aem64.json</summaryFile>
                                <summaryFile>${project.build.directory}/oakpal-plugin/reports/content-class-aem65.json</summaryFile>
                                <summaryFile>${project.build.directory}/oakpal-plugin/reports/oakpal-summary-min.json</summaryFile>
                            </summaryFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <!-- configuration to create minimal package -->
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-min-package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>${pom.basedir}/../content/src/main/script/CreateMinPackage.groovy</source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.artifactId}-${project.version}-min.zip</file>
                                    <type>zip</type>
                                    <classifier>min</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>acs-aem-commons-oakpal-checks</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
            <classifier>apis</classifier>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>autoInstallUiContentPackage</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>
    </profiles>
</project>
