<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
    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>
    <parent>
        <groupId>org.apache.sling</groupId>
        <artifactId>sling</artifactId>
        <version>47</version>
        <relativePath />
    </parent>

    <artifactId>org.apache.sling.starter</artifactId>
    <version>12</version>

    <name>Apache Sling Starter Application</name>
    <description>
        The Sling Starter demo application.
    </description>

    <scm>
        <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter.git</connection>
        <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter.git</developerConnection>
        <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-starter.git</url>
        <tag>org.apache.sling.starter-12</tag>
    </scm>

    <properties>
        <sling.java.version>8</sling.java.version>
        <starter.min.bundles.count>126</starter.min.bundles.count>

        <!-- versions to be replaced in the feature files -->
        <asm.version>9.2</asm.version>
        <jackrabbit.version>2.20.4</jackrabbit.version>
        <oak.version>1.42.0</oak.version>
        <slf4j.version>1.7.36</slf4j.version>
        <composum.nodes.version>4.0.1</composum.nodes.version>
        <jackson.version>2.13.1</jackson.version>
        <groovy.version>3.0.9</groovy.version>
        <!-- skip index generation for all builds except for CI and release -->
        <bnd.index.generation.skip>true</bnd.index.generation.skip>
        <docker.skip>true</docker.skip>
        <docker.label>snapshot</docker.label>
        <mongo.container.image>mongo:4.4.6</mongo.container.image>
        <it.startTimeoutSeconds>60</it.startTimeoutSeconds>
        <!-- used for reproducible builds (https://maven.apache.org/guides/mini/guide-reproducible-builds.htm), automatically updated during release -->
        <project.build.outputTimestamp>1647263058</project.build.outputTimestamp>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${basedir}</directory>
                            <includes>
                                <include>sling/**</include>
                                <include>coverage.ec</include>
                                <include>launcher/**</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>slingfeature-maven-plugin</artifactId>
                <version>1.5.16</version>
                <extensions>true</extensions>
                <configuration>
                    <replacePropertyVariables>asm.version,jackrabbit.version,groovy.version,oak.version,slf4j.version,composum.nodes.version,jackson.version</replacePropertyVariables>
                    <aggregates>
                        <aggregate>
                            <classifier>oak_tar</classifier>
                            <filesInclude>*.json</filesInclude>
                            <filesInclude>oak/*.json</filesInclude>
                            <filesInclude>oak/persistence/oak_persistence_sns.json</filesInclude>
                            <filesInclude>app/*.json</filesInclude>
                            <title>Sling With Oak Segment NS Persistence</title>
                        </aggregate>
                        <aggregate>
                            <classifier>oak_mongo</classifier>
                            <filesInclude>*.json</filesInclude>
                            <filesInclude>oak/*.json</filesInclude>
                            <filesInclude>oak/persistence/oak_persistence_mongods.json</filesInclude>
                            <filesInclude>app/*.json</filesInclude>
                            <title>Sling With Oak Document NS Mongo Persistence</title>
                        </aggregate>
                        <aggregate>
                            <classifier>nosample_base</classifier>
                            <filesInclude>*.json</filesInclude>
                            <filesInclude>oak/*.json</filesInclude>
                            <title>Sling With No Samples and No Persistence</title>
                        </aggregate>
                    </aggregates>
                    <scans>
                        <scan>
                            <includeClassifier>oak_tar</includeClassifier>
                            <includeClassifier>oak_mongo</includeClassifier>
                            <includeClassifier>nosample_base</includeClassifier>
                        </scan>
                    </scans>
                    <archives>
                        <archive>
                            <classifier>oak_tar_far</classifier>
                            <includeClassifier>oak_tar</includeClassifier>
                        </archive>
                        <archive>
                            <classifier>oak_mongo_far</classifier>
                            <includeClassifier>oak_mongo</includeClassifier>
                        </archive>
                    </archives>
                    <repositories>
                        <repository>
                            <includeClassifier>oak_tar</includeClassifier>
                            <includeClassifier>oak_mongo</includeClassifier>
                            <includeClassifier>docker</includeClassifier>
                        </repository>
                    </repositories>
                </configuration>
                <executions>
                    <execution>
                        <id>aggregate-features</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>aggregate-features</goal>
                            <goal>analyse-features</goal>
                            <goal>attach-features</goal>
                            <goal>attach-featurearchives</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>create-repository</id>
                        <phase>package</phase>
                        <goals>
                            <goal>repository</goal>
                        </goals>
                    </execution>
               </executions>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-feature-launcher</id>
                        <goals>
                            <goal>get</goal>
                            <goal>copy</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <!-- 1.1.28 and newer versions don't work out-of-the-box due to SLING-10956 -->
                            <artifact>org.apache.sling:org.apache.sling.feature.launcher:1.1.26</artifact>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- generate bnd OSGi index (https://github.com/bndtools/bnd/tree/master/maven/bnd-indexer-maven-plugin) -->
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-indexer-maven-plugin</artifactId>
                <version>6.2.0</version>
                <executions>
                    <execution>
                        <id>index</id>
                        <goals>
                            <goal>index</goal>
                        </goals>
                        <configuration>
                            <scopes>provided</scopes>
                            <skip>${bnd.index.generation.skip}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- reserve network ports for the integration tests -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>reserve-network-port</id>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <portNames>
                                <portName>http.port</portName>
                                <portName>http.port.mongo</portName>
                                <portName>mongo.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target if="${docker.skip}">
                                <echo>WARNING: docker.skip is ${docker.skip}, Docker-based tests will not be executed.</echo>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
                Start a MongoDB container for the corresponding tests.
                Must be declared before the feature-launcher-maven-plugin
                so that the container is up before the corresponding Sling
                instance starts.
            -->
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.39.0</version>
                <configuration>
                    <skip>${docker.skip}</skip>
                    <images>
                        <image>
                            <alias>mongo</alias>
                            <name>${mongo.container.image}</name>
                            <run>
                                <ports>
                                    <port>${mongo.port}:27017</port>
                                </ports>
                                <wait>
                                    <log>CONTROL</log>
                                    <time>60000</time>
                                </wait>
                            </run>
                        </image>
                        <image>
                            <name>apache/sling:${docker.label}</name>
                            <build>
                                <dockerFile>Dockerfile</dockerFile>
                                <contextDir>${project.basedir}</contextDir>
                            </build>
                        </image>
                    </images>
                    <stopMode>kill</stopMode>
                </configuration>
                <executions>
                    <execution>
                        <id>start-mongo</id>
                        <!-- must run prior feature-launcher-maven-plugin:start  -->
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-mongo</id>
                        <!-- must run after feature-launcher-maven-plugin:stop  -->
                        <phase>verify</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>build-docker-image</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- launch the Sling instances to test -->
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>feature-launcher-maven-plugin</artifactId>
                <version>0.1.2</version>
                <configuration>
                    <launches>
                        <launch>
                            <id>sling-12-oak-tar</id>
                            <feature>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${project.artifactId}</artifactId>
                                <version>${project.version}</version>
                                <classifier>oak_tar</classifier>
                                <type>slingosgifeature</type>
                            </feature>
                            <launcherArguments>
                                <frameworkProperties>
                                    <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port>
                                </frameworkProperties>
                            </launcherArguments>
                            <startTimeoutSeconds>${it.startTimeoutSeconds}</startTimeoutSeconds>
                        </launch>
                        <launch>
                            <id>sling-12-oak-mongo</id>
                            <skip>${docker.skip}</skip>
                            <feature>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${project.artifactId}</artifactId>
                                <version>${project.version}</version>
                                <classifier>oak_mongo</classifier>
                                <type>slingosgifeature</type>
                            </feature>
                            <launcherArguments>
                                <frameworkProperties>
                                    <org.osgi.service.http.port>${http.port.mongo}</org.osgi.service.http.port>
                                </frameworkProperties>
                            </launcherArguments>
                            <environmentVariables>
                                <MONGODB_PORT>${mongo.port}</MONGODB_PORT>
                            </environmentVariables>
                            <startTimeoutSeconds>${it.startTimeoutSeconds}</startTimeoutSeconds>
                        </launch>
                    </launches>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>start</goal>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- run the ITs -->
            <plugin>
               <artifactId>maven-failsafe-plugin</artifactId>
               <executions>
                   <execution>
                       <goals>
                           <goal>integration-test</goal>
                           <goal>verify</goal>
                       </goals>
                   </execution>
               </executions>
               <configuration>
                   <systemPropertyVariables>
                       <starter.http.test.ports>false:${http.port},${docker.skip}:${http.port.mongo}</starter.http.test.ports>
                       <starter.min.bundles.count>${starter.min.bundles.count}</starter.min.bundles.count>
                       <!-- Comma-separated list of paths to check for 200 status (added for SLING-10402) -->
                       <starter.check.paths>
                            /slingshot/users/slingshot1/travel/home/images/home.jpg,
                            /slingshot/resources/images/background.jpg,
                            /slingshot/users/slingshot2/places/landing/images/landing.jpg,
                            /starter.html,
                            /bin/browser.html,
                            /system/console/bundles,
                        </starter.check.paths>
                   </systemPropertyVariables>
               </configuration>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <!-- Extend RAT configuration from parent pom -->
                    <groupId>org.apache.rat</groupId>
                    <artifactId>apache-rat-plugin</artifactId>
                    <configuration>
                        <excludes combine.children="append">
                            <!-- Exclude sling instance -->
                            <exclude>sling/**</exclude>
                            <exclude>launcher/**</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.utils</artifactId>
            <version>1.11.8</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    
    <profiles>
        <profile>
            <!-- enabled during release builds -->
            <id>apache-release</id>
            <properties>
               <bnd.index.generation.skip>false</bnd.index.generation.skip>
            </properties>
        </profile>
        <profile>
            <id>ci</id>
            <!-- enabled during ci builds -->
            <activation>
                <property>
                    <name>ci</name>
                </property>
            </activation>
            <properties>
               <bnd.index.generation.skip>false</bnd.index.generation.skip>
               <docker.skip>false</docker.skip>
            </properties>
        </profile>
    </profiles>
</project>
