<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ ACS AEM Commons
  ~
  ~ Copyright (C) 2013 - 2023 Adobe
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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>6.11.0</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.apps</artifactId>
    <name>ACS AEM Commons UI.Apps Package</name>
    <description>ACS AEM Commons content package containing code (/apps).</description>
    <packaging>content-package</packaging>

    <build>

        <plugins>
            <plugin>
                <groupId>org.apache.jackrabbit</groupId>
                <artifactId>filevault-package-maven-plugin</artifactId>
                <configuration>
                    <!-- overwrite rep:ACE nodes defining policies for acs-aem-commons-owned service principals -->
                    <accessControlHandling>merge</accessControlHandling>
                    <packageType>application</packageType>
                </configuration>
                <executions>
                    <execution>
                        <id>default-metadata</id>
                        <goals>
                            <goal>generate-metadata</goal>
                        </goals>
                        <configuration>
                            <dependencies>
                                <dependency>
                                    <group>day/cq60/product</group>
                                    <name>cq-content</name>
                                    <version>[6.5.10,)</version><!-- version shipped with AEM 6.5.0 GA -->
                                </dependency>
                            </dependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>net.adamcin.oakpal</groupId>
                <artifactId>oakpal-maven-plugin</artifactId>
                <configuration>
                    <deferBuildFailure>true</deferBuildFailure>
                    <checklists>
                        <checklist>acs-internal</checklist>
                    </checklists>

                    <!-- Enforce separation of content and code (CODE ONLY) -->
                    <checks>
                        <check>
                            <name>basic/paths</name>
                            <config>
                                <rules>
                                    <rule>
                                        <pattern>/apps(/.*)?</pattern>
                                        <type>allow</type>
                                    </rule>
                                </rules>
                            </config>
                        </check>
                        <!-- Removed verify-acls-on-apps as ACLs have been moved to repo init, which OakPal does not see -->
                    </checks>

                    <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-verify</id>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <summaryFiles>
                                <summaryFile>${project.build.directory}/oakpal-plugin/reports/content-class-aem65.json
                                </summaryFile>
                            </summaryFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.cj.jshintmojo</groupId>
                <artifactId>jshint-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>lint</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <directories>
                        <directory>src/main/content/jcr_root</directory>
                    </directories>
                    <failOnError>true</failOnError>
                    <globals>jQuery,window,$</globals>
                    <excludes>
                        <exclude>/src/main/content/jcr_root/apps/acs-commons/extensions/contentfinder/audio.js</exclude>
                        <exclude>
                            /src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-controlled-processes/clientlibs/js/vendor
                        </exclude>
                        <exclude>
                            /src/main/content/jcr_root/apps/acs-commons/components/utilities/version-compare/clientlibs/js/vendor/jquery.jsPlumb-1.7.2-min.js
                        </exclude>
                        <exclude>/src/main/content/jcr_root/apps/acs-commons/clientlibs/vendor</exclude>
                        <exclude>/src/main/content/jcr_root/apps/acs-commons/authoring/vendor</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.adobe.acs</groupId>
            <artifactId>acs-aem-commons-bundle</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.adobe.acs</groupId>
            <artifactId>acs-aem-commons-oakpal-checks</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- put UberJar last so that more specific artifacts take precedence -->
        <dependency>
            <groupId>com.adobe.aem</groupId>
            <artifactId>uber-jar</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>cloud</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <contentPackageFile>${project.build.directory}/${project.build.finalName}-cloud.zip</contentPackageFile>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.jackrabbit</groupId>
                        <artifactId>filevault-package-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cloud-metadata</id>
                                <goals>
                                    <goal>generate-metadata</goal>
                                </goals>
                                <configuration>
                                    <classifier>cloud</classifier>
                                    <dependencies>
                                        <dependency>
                                            <group>day/cq60/product</group>
                                            <name>cq-content</name>
                                            <version>[6.6,)</version><!-- version shipped with AEM Cloud SDK -->
                                        </dependency>
                                    </dependencies>
                                </configuration>
                            </execution>
                            <execution>
                                <id>cloud-package</id>
                                <goals>
                                    <goal>package</goal>
                                </goals>
                                <configuration>
                                    <classifier>cloud</classifier>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>autoInstallUiAppsPackage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.day.jcr.vault</groupId>
                        <artifactId>content-package-maven-plugin</artifactId>
                        <configuration>
                            <packageFile>${contentPackageFile}</packageFile>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install-content-package</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>install</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
