<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
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 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>

  <groupId>io.kestros.commons</groupId>
  <artifactId>kestros-root-project</artifactId>

  <version>0.2.1</version>

  <name>Kestros Root Project</name>
  <description>
    Base Sling project build manager. Contains dependency and plugin versions for
    building and installing Bundles and Packages to Sling instances.
  </description>
  <url>https://www.kestros.io</url>

  <packaging>pom</packaging>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <inceptionYear>2020</inceptionYear>

  <organization>
    <name>Kestros, Inc.</name>
    <url>https://www.kestros.io</url>
  </organization>

  <scm>
    <connection>scm:git:git://github.com/kestros/kestros-root-project.git</connection>
    <developerConnection>scm:git:ssh://github.com:kestros/kestros-root-project.git
    </developerConnection>
    <url>https://github.com/kestros/kestros-root-project/tree/master</url>
  </scm>

  <developers>
    <developer>
      <name>Danny Moulton</name>
      <email>danny.moulton@kestros.io</email>
      <organization>Kestros, Inc.</organization>
      <organizationUrl>https://www.kestros.io</organizationUrl>
    </developer>
    <developer>
      <name>Kevin O'Brien</name>
      <email>kevin.obrien@kestros.io</email>
      <organization>Kestros, Inc.</organization>
      <organizationUrl>https://www.kestros.io</organizationUrl>
    </developer>
  </developers>

  <properties>
    <sling.host>localhost</sling.host>
    <sling.port>8080</sling.port>
    <sling.username>admin</sling.username>
    <sling.password>admin</sling.password>
    <sling.protocol>http</sling.protocol>
    <sling.java.version>8</sling.java.version>
  </properties>

  <modules>
    <module>kestros-build-tools</module>
    <module>kestros-parent</module>
    <module>kestros-parent-strict</module>
  </modules>

  <dependencyManagement>
    <dependencies>
      <!-- javax Dependencies -->
      <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.2</version>
      </dependency>

      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
      </dependency>

      <!-- OSGi Dependencies -->
      <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.core</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.cmpn</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.osgi</groupId>
        <artifactId>osgi.annotation</artifactId>
        <version>7.0.0</version>
        <scope>provided</scope>
      </dependency>

      <!-- Sling Dependencies -->
      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.models.api</artifactId>
        <version>1.3.6</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.models.impl</artifactId>
        <version>1.4.10</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.servlets.annotations</artifactId>
        <version>1.2.4</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.event.api</artifactId>
        <version>1.0.0</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.scripting.sightly.compiler.java</artifactId>
        <version>1.0.26-1.4.0</version>
      </dependency>

      <!-- Felix Health Checks -->
      <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.healthcheck.api</artifactId>
        <version>2.0.2</version>
        <scope>provided</scope>
      </dependency>

      <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.healthcheck.annotation</artifactId>
        <version>2.0.0</version>
        <scope>provided</scope>
      </dependency>

      <!-- Jackson Dependencies -->
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.9.9</version>
      </dependency>

      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.9</version>
      </dependency>

      <!-- Testing Dependencies -->
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
      </dependency>

      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <version>2.23.0</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
        <version>2.3.10</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
        <version>2.1.0</version>
      </dependency>

      <!-- Findbug Annotations -->
      <dependency>
        <groupId>com.google.code.findbugs</groupId>
        <artifactId>annotations</artifactId>
        <version>3.0.0</version>
        <scope>provided</scope>
      </dependency>

      <!-- Logging -->
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.30</version>
      </dependency>

      <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.commons.log</artifactId>
        <version>5.0.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.cmpn</artifactId>
    </dependency>

    <dependency>
      <groupId>org.osgi</groupId>
      <artifactId>osgi.annotation</artifactId>
    </dependency>

    <!-- Jackson -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>

    <!-- Findbugs Annotations -->
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>annotations</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.models.api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.models.impl</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.event.api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.commons.log</artifactId>
    </dependency>


    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.healthcheck.api</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.healthcheck.annotation</artifactId>
    </dependency>

    <!-- Testing-->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.sling</groupId>
      <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>

        <!-- Maven Enforcer -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.0.0-M2</version>
          <executions>
            <execution>
              <id>enforce-property-values</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireProperty>
                    <property>sling.java.version</property>
                    <regex>^(8|9|1[0-9])$</regex>
                    <regexMessage>
                      The value of the "sling.java.version" property should comply with the
                      following pattern: ^(8|9|1[0-9])$.
                    </regexMessage>
                  </requireProperty>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-java-version</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireJavaVersion>
                    <version>1.8.0</version>
                    <message>Apache Sling must be compiled with Java 8 or higher.</message>
                  </requireJavaVersion>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>enforce-maven-version</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <requireMavenVersion>
                    <version>3.3.9</version>
                  </requireMavenVersion>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>ban-maven-scr-plugin</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <bannedPlugins>
                    <excludes>
                      <exclude>org.apache.felix:maven-scr-plugin</exclude>
                    </excludes>
                    <message>Felix SCR annotations and the maven-scr-plugin are no longer supported
                      - please migrate to OSGi.
                    </message>
                  </bannedPlugins>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>ban-felix-scr-annotations</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <bannedDependencies>
                    <excludes>
                      <exclude>org.apache.felix:org.apache.felix.scr.annotations</exclude>
                    </excludes>
                    <message>Felix SCR annotations and the maven-scr-plugin are no longer supported
                      - please migrate to OSGi.
                    </message>
                  </bannedDependencies>
                </rules>
              </configuration>
            </execution>
            <execution>
              <id>ban-maven-sling-plugin</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <bannedPlugins>
                    <excludes>
                      <exclude>org.apache.sling:maven-sling-plugin</exclude>
                    </excludes>
                    <message>Please change all occurrences of maven-sling-plugin to
                      sling-maven-plugin (plugin was renamed).
                    </message>
                  </bannedPlugins>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- Maven Javadoc -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.1.1</version>
          <configuration>
            <source>8</source>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Maven Source -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.1.0</version>
          <inherited>true</inherited>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Maven Compiler -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <failOnError>true</failOnError>
            <failOnWarning>false</failOnWarning>
          </configuration>
        </plugin>

        <!-- Maven Bundle Plugin -->
        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>5.1.1</version>
        </plugin>

        <!-- FileVault Content Package Plugin -->
        <plugin>
          <groupId>org.apache.jackrabbit</groupId>
          <artifactId>filevault-package-maven-plugin</artifactId>
          <version>1.0.3</version>
          <extensions>true</extensions>
          <executions>
            <execution>
              <goals>
                <goal>generate-metadata</goal>
                <goal>package</goal>
                <goal>analyze-classes</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <packageType>mixed</packageType>
            <failOnMissingEmbed>true</failOnMissingEmbed>
            <accessControlHandling>merge</accessControlHandling>
            <allowIndexDefinitions>true</allowIndexDefinitions>
            <embeddedTarget>${sling.embeddedTarget}</embeddedTarget>
            <filterSource>src/content/META-INF/vault/filter.xml</filterSource>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>sling-maven-plugin</artifactId>
          <version>2.4.2</version>
        </plugin>

        <!-- Content Package Install Plugin -->
        <plugin>
          <groupId>io.wcm.maven.plugins</groupId>
          <artifactId>wcmio-content-package-maven-plugin</artifactId>
          <version>1.6.18</version>
          <executions>
            <execution>
              <goals>
                <goal>install</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <serviceURL>${sling.protocol}://${sling.host}:${sling.port}/bin/cpm/package.service.html
            </serviceURL>
            <userId>${sling.username}</userId>
            <password>${sling.password}</password>
            <packageFile>target/${project.artifactId}-${project.version}.zip</packageFile>
          </configuration>
        </plugin>

        <!-- HTL Plugin -->
        <plugin>
          <groupId>org.apache.sling</groupId>
          <artifactId>htl-maven-plugin</artifactId>
          <version>1.2.2-1.4.0</version>
          <configuration>
            <failOnWarnings>true</failOnWarnings>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M3</version>
          <configuration>
            <trimStackTrace>false</trimStackTrace>
            <includes>
              <include>**/*Test.class</include>
            </includes>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.4</version>
          <configuration>
            <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
            <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
            <output>file</output>
            <append>true</append>
            <excludes>
              <exclude>*MethodAccess</exclude>
            </excludes>
          </configuration>
          <executions>
            <execution>
              <id>jacoco-initialize</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <phase>test-compile</phase>
            </execution>
            <execution>
              <id>jacoco-site</id>
              <phase>verify</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.1.1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>empty-javadoc-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <classifier>javadoc</classifier>
              <classesDirectory>${basedir}/javadoc</classesDirectory>
            </configuration>
          </execution>
          <execution>
            <id>empty-sources-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <classifier>sources</classifier>
              <classesDirectory>${basedir}/javadoc</classesDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
      </plugin>

      <plugin>
        <groupId>org.apache.sling</groupId>
        <artifactId>htl-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>scr-metadata</id>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <supportIncrementalBuild>true</supportIncrementalBuild>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <exportScr>true</exportScr>
          <instructions>
            <!-- Enable processing of OSGI DS component annotations -->
            <_dsannotations>*</_dsannotations>
            <!-- Enable processing of OSGI metatype annotations -->
            <_metatypeannotations>*</_metatypeannotations>
            <Export-Package>${rootPackage}.*</Export-Package>
            <Sling-Model-Packages>
              ${rootPackage}
            </Sling-Model-Packages>
            <Bundle-Category>${bundleCategory}</Bundle-Category>
          </instructions>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <profiles>

    <profile>
      <id>installBundle</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.sling</groupId>
            <artifactId>sling-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>install-bundle</id>
                <goals>
                  <goal>install</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <slingUrl>${sling.protocol}://${sling.host}:${sling.port}/system/console</slingUrl>
              <user>${sling.username}</user>
              <password>${sling.password}</password>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>
