<?xml version="1.0"?>
<!--
	Copyright 2020 Adobe. All rights reserved.
	This file is licensed to you 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 REPRESENTATIONS
	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/xsd/maven-4.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.dx</groupId>
        <artifactId>parent-reactor</artifactId>
        <version>16</version>
        <relativePath>..</relativePath>
    </parent>

    <groupId>com.adobe.dx</groupId>
    <artifactId>parent</artifactId>
    <version>16</version>
    <packaging>pom</packaging>

    <properties>
        <aem.host>localhost</aem.host>
        <aem.port>4502</aem.port>
        <aem.publish.host>localhost</aem.publish.host>
        <aem.publish.port>4503</aem.publish.port>
        <aem.version>6.4.8.1</aem.version>
        <aem.contextPath />
        <sling.url>http://${aem.host}:${aem.port}${aem.contextPath}</sling.url>
        <bnd.version>4.2.0</bnd.version>
        <bundle.additional.properties />
        <frontend-maven-plugin.version>1.7.6</frontend-maven-plugin.version>
        <node.version>v12.17.0</node.version>
        <npm.version>6.14.4</npm.version>
        <gpg.useagent>true</gpg.useagent>
        <jacoco.version>0.8.3</jacoco.version>
        <jacoco.data.file>${project.build.directory}/jacoco.exec</jacoco.data.file>
        <java.version>8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <sling.user>admin</sling.user>
        <sling.password>admin</sling.password>
        <slf4j.version>1.7.6</slf4j.version>
        <surefire.version>3.0.0-M3</surefire.version>
        <vault.user>admin</vault.user>
        <vault.password>admin</vault.password>
    </properties>

    <name>${project.prefix} - DX Parent</name>

    <!-- ======================================================================= -->
    <!-- R E P O R T I N G                                                       -->
    <!-- ======================================================================= -->
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <stylesheet>maven</stylesheet>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <links>
                        <link>https://docs.oracle.com/javase/${java.version}/docs/api/</link>
                        <link>https://docs.oracle.com/javaee/7/api/</link>
                        <link>https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/</link>
                        <link>https://sling.apache.org/apidocs/sling9/</link>
                        <link>https://github.com/adobe/aem-core-wcm-components</link>
                        <link>https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/</link>
                        <link>https://jackrabbit.apache.org/api/2.12/</link>
                        <link>https://osgi.org/javadoc/r6/core/</link>
                        <link>https://osgi.org/javadoc/r6/annotation/</link>
                        <link>https://osgi.org/javadoc/r6/cmpn/</link>
                    </links>
                    <excludePackageNames>*.impl:*.internal</excludePackageNames>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

    <!-- ======================================================================= -->
    <!-- B U I L D                                                               -->
    <!-- ======================================================================= -->
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.18.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.jackrabbit</groupId>
                    <artifactId>filevault-package-maven-plugin</artifactId>
                    <version>1.0.1</version>
                    <configuration>
                        <failOnMissingEmbed>true</failOnMissingEmbed>
                        <filterSource>${project.basedir}/src/content/META-INF/vault/filter.xml</filterSource>
                        <!-- temporary, until https://issues.apache.org/jira/browse/JCRVLT-219 is fixed -->
                        <failOnDependencyErrors>false</failOnDependencyErrors>
                        <excludes>
                            <!-- exclude .vlt control files in the package -->
                            <exclude>**/.vlt</exclude>
                            <exclude>**/.vltignore</exclude>
                            <exclude>**/.gitignore</exclude>
                            <exclude>**/*.iml</exclude>
                            <exclude>**/.classpath</exclude>
                            <exclude>**/.project</exclude>
                            <exclude>**/.eslintrc</exclude>
                            <exclude>**/.editorconfig</exclude>
                            <exclude>**/.stylelintrc.yaml</exclude>
                            <exclude>**/.eslintignore</exclude>
                            <exclude>**/.settings</exclude>
                            <exclude>**/.DS_Store</exclude>
                            <exclude>**/target/**</exclude>
                            <exclude>**/node/**</exclude>
                            <exclude>**/node_modules/**</exclude>
                            <exclude>**/pom.xml</exclude>
                        </excludes>
                        <group>adobe/dx</group>
                        <repositoryStructurePackages>
                            <repositoryStructurePackage>
                                <groupId>com.adobe.dx</groupId>
                                <artifactId>repository-structure</artifactId>
                            </repositoryStructurePackage>
                        </repositoryStructurePackages>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>htl-maven-plugin</artifactId>
                    <version>1.2.0-1.4.0</version>
                    <configuration>
                        <failOnWarnings>true</failOnWarnings>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.sling</groupId>
                    <artifactId>sling-maven-plugin</artifactId>
                    <version>2.4.0</version>
                    <configuration>
                        <slingUrl>${sling.url}/system/console</slingUrl>
                        <user>${sling.user}</user>
                        <password>${sling.password}</password>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>biz.aQute.bnd</groupId>
                    <artifactId>bnd-maven-plugin</artifactId>
                    <version>${bnd.version}</version>
                    <executions>
                        <execution>
                            <id>bnd-process</id>
                            <goals>
                                <goal>bnd-process</goal>
                            </goals>
                            <configuration>
                                <bnd><![CDATA[
Bundle-Category: Adobe DX
Bundle-SymbolicName: ${project.artifactId}
Import-Package: javax.annotation;version=0.0.0,*
-exportcontents: ${packages;VERSIONED}
${bundle.additional.properties}
-snapshot: ${tstamp;yyyyMMddHHmmssSSS}
                                ]]></bnd>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>biz.aQute.bnd</groupId>
                    <artifactId>bnd-baseline-maven-plugin</artifactId>
                    <version>${bnd.version}</version>
                    <configuration>
                        <failOnMissing>false</failOnMissing>
                    </configuration>
                    <executions>
                        <execution>
                            <id>baseline</id>
                            <goals>
                                <goal>baseline</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.0.0</version>
                    <configuration>
                        <stylesheet>maven</stylesheet>
                        <encoding>${project.build.sourceEncoding}</encoding>
                        <links>
                            <link>https://docs.oracle.com/javase/${java.version}/docs/api/</link>
                            <link>https://docs.oracle.com/javaee/7/api/</link>
                            <link>https://docs.adobe.com/docs/en/spec/jsr170/javadocs/jcr-2.0/</link>
                            <link>https://sling.apache.org/apidocs/sling9/</link>
                            <link>https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/</link>
                            <link>https://jackrabbit.apache.org/api/2.12/</link>
                            <link>https://osgi.org/javadoc/r6/core/</link>
                            <link>https://osgi.org/javadoc/r6/annotation/</link>
                            <link>https://osgi.org/javadoc/r6/cmpn/</link>
                        </links>
                        <excludePackageNames>*.impl:*.internal</excludePackageNames>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>findbugs-maven-plugin</artifactId>
                    <version>3.0.4</version>
                    <configuration>
                        <effort>Max</effort>
                        <xmlOutput>true</xmlOutput>
                        <excludeFilterFile>src/test/resources/findbugs-exclude.xml</excludeFilterFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>find-bugs</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>xml-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>validate</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <validationSets>
                            <validationSet>
                                <dir>.</dir>
                                <includes>
                                    <include>**/*.xml</include>
                                </includes>
                                <excludes>
                                    <exclude>**/node/**</exclude>
                                    <exclude>**/node_modules/**</exclude>
                                    <exclude>**/target/**</exclude>
                                </excludes>
                            </validationSet>
                        </validationSets>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.day.jcr.vault</groupId>
                    <artifactId>content-package-maven-plugin</artifactId>
                    <version>1.0.2</version>
                    <configuration>
                        <targetURL>${sling.url}/crx/packmgr/service.jsp</targetURL>
                        <failOnError>true</failOnError>
                        <verbose>true</verbose>
                        <userId>${vault.user}</userId>
                        <userId>${vault.password}</userId>
                        <maxUploadAttemps>3</maxUploadAttemps>
                    </configuration>
                </plugin>
                <plugin>
                    <inherited>false</inherited>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>${frontend-maven-plugin.version}</version>
                    <configuration>
                        <nodeVersion>${node.version}</nodeVersion>
                        <npmVersion>${npm.version}</npmVersion>
                        <workingDirectory>../../</workingDirectory>
                        <installDirectory>../../</installDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>install node and npm</id>
                            <goals>
                                <goal>install-node-and-npm</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>npm install collection-view</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                            <configuration>
                                <arguments>install --no-optional react-collection-view-4.1.5.tgz</arguments>
                            </configuration>
                        </execution>
                        <execution>
                            <id>npm install</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                            <configuration>
                                <arguments>install --no-optional</arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>[3.3.1,)</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <message>Project must be compiled with Java ${java.version} or higher</message>
                                    <version>1.${java.version}</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>sonar</id>
            <properties>
                <sonar.host.url>https://sonarcloud.io</sonar.host.url>
                <sonar.organization>adobeinc</sonar.organization>
                <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco-merged/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
                <sonar.javascript.lcov.reportPaths>js_reports/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
                <sonar.testExecutionReportPaths>apps/admin/app/js_reports/test-reporter.xml</sonar.testExecutionReportPaths>
                <sonar.test.inclusions>**/*.test.js</sonar.test.inclusions>
                <sonar.verbose>true</sonar.verbose>
            </properties>
        </profile>
        <profile>
            <id>jacoco-report</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-unit.exec</destFile>
                                </configuration>
                            </execution>
                            <execution>
                                <id>prepare-agent-integration</id>
                                <goals>
                                    <goal>prepare-agent-integration</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                                </configuration>
                            </execution>
                            <execution>
                                <id>report</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${project.build.directory}/jacoco-unit.exec</dataFile>
                                    <outputDirectory> ${project.reporting.outputDirectory}/jacoco-unit</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>report-integration</id>
                                <goals>
                                    <goal>report-integration</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
                                    <outputDirectory> ${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>merge-unit-and-it</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>merge</goal>
                                </goals>
                                <configuration>
                                    <destFile>${project.build.directory}/jacoco-merged.exec</destFile>
                                    <fileSets>
                                        <fileSet>
                                            <directory>${project.build.directory}</directory>
                                            <includes>
                                                <include>jacoco-unit.exec</include>
                                                <include>jacoco-it.exec</include>
                                            </includes>
                                        </fileSet>
                                    </fileSets>
                                </configuration>
                            </execution>
                            <execution>
                                <id>check-coverage</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                                    <rules>
                                        <rule>
                                            <element>BUNDLE</element>
                                            <limits>
                                                <limit>
                                                    <counter>INSTRUCTION</counter>
                                                    <value>COVEREDRATIO</value>
                                                    <minimum>0.80</minimum>
                                                </limit>
                                            </limits>
                                        </rule>
                                        <rule>
                                            <element>CLASS</element>
                                            <limits>
                                                <limit>
                                                    <counter>INSTRUCTION</counter>
                                                    <value>COVEREDRATIO</value>
                                                    <minimum>0.80</minimum>
                                                </limit>
                                            </limits>
                                        </rule>
                                    </rules>
                                </configuration>
                            </execution>
                            <execution>
                                <id>report-merged</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <configuration>
                                    <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                                    <outputDirectory> ${project.reporting.outputDirectory}/jacoco-merged</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <dependencyManagement>
        <dependencies>
            <!-- Aggregates (rather use individual artifacts referenced below) -->
            <!-- Core R6 -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>osgi.core</artifactId>
                <version>6.0.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- Compendium R6 -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>osgi.cmpn</artifactId>
                <version>6.0.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- Service Component 1.4, Compendium R7 (https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/component/package-frame.html) -->
            <!-- and component property types (https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/component/propertytypes/package-frame.html) -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.service.component</artifactId>
                <version>1.4.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- Event Admin 1.3.1, Compendium R6 (https://osgi.org/javadoc/r6/cmpn/org/osgi/service/event/package-summary.html) -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.service.event</artifactId>
                <version>1.3.1</version>
                <scope>provided</scope>
            </dependency>
            <!-- OSGi annotations (OSGi R7) -->
            <!-- https://osgi.org/javadoc/osgi.annotation/7.0.0/org/osgi/annotation/versioning/package-frame.html -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.annotation.versioning</artifactId>
                <version>1.1.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- https://osgi.org/javadoc/osgi.annotation/7.0.0/org/osgi/annotation/bundle/package-frame.html -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.annotation.bundle</artifactId>
                <version>1.0.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- https://osgi.org/javadoc/osgi.cmpn/7.0.0/org/osgi/service/component/annotations/package-frame.html -->
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.service.component.annotations</artifactId>
                <version>1.4.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.models.api</artifactId>
                <version>1.3.6</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.annotation</groupId>
                <artifactId>javax.annotation-api</artifactId>
                <version>1.3.2</version>
                <scope>provided</scope>
            </dependency>
            <!-- Logging Dependencies -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
                <scope>provided</scope>
            </dependency>
            <!-- Apache Sling Dependencies -->
            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.commons.osgi</artifactId>
                <version>2.4.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.commons.johnzon</artifactId>
                <version>1.0.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- Servlet API -->
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jetbrains</groupId>
                <artifactId>annotations</artifactId>
                <version>16.0.2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.adobe.cq</groupId>
                <artifactId>core.wcm.components.all</artifactId>
                <version>2.8.0</version>
                <type>zip</type>
            </dependency>
            <dependency>
                <groupId>com.adobe.dx</groupId>
                <artifactId>repository-structure</artifactId>
                <version>16</version>
                <type>zip</type>
            </dependency>
            <!-- Uber Jar-->
            <dependency>
                <groupId>com.adobe.aem</groupId>
                <artifactId>uber-jar</artifactId>
                <version>${aem.version}</version>
                <classifier>apis</classifier>
                <scope>provided</scope>
            </dependency>
            <!-- Testing dependencies -->
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>5.6.0</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>1.9.5</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

</project>
