<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.sling</groupId>
        <artifactId>sling-bundle-parent</artifactId>
        <version>62</version>
        <relativePath />
    </parent>

    <artifactId>org.apache.sling.auth.oauth-client</artifactId>
    <version>0.1.6</version>

    <name>Apache Sling OAuth Client</name>
    <description>Apache Sling OAuth 2.0 client with OIDC support</description>

    <scm>
        <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git</connection>
        <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-oauth-client.git</developerConnection>
        <tag>org.apache.sling.auth.oauth-client-0.1.6</tag>
        <url>https://github.com/apache/sling-org-apache-sling-auth-oauth-client.git</url>
    </scm>

    <properties>
        <sling.java.version>11</sling.java.version>
        <project.build.outputTimestamp>1763123464</project.build.outputTimestamp>
        <it.startTimeoutSeconds>60</it.startTimeoutSeconds>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.service.component.annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.service.metatype.annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.annotation.versioning</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.servlets.annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.jcr</groupId>
            <artifactId>jcr</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-jackrabbit-api</artifactId>
            <version>1.40.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.api</artifactId>
            <version>2.25.4</version>
            <scope>provided</scope>
        </dependency>
        <!-- TODO - revisit if we can remove dependency-->
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.commons.crypto</artifactId>
            <version>1.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>oauth2-oidc-sdk</artifactId>
            <version>11.23.1</version>
            <scope>provided</scope>
        </dependency>
        <!-- Redis persistence support-->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>5.0.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.24.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>1.17.6</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>1.17.6</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.dasniko</groupId>
            <artifactId>testcontainers-keycloak</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.redis.testcontainers</groupId>
            <artifactId>testcontainers-redis</artifactId>
            <version>1.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.testing.clients</artifactId>
            <version>3.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.testing.sling-mock.junit5</artifactId>
            <version>3.4.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
            <version>3.1.2-1.40.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.testing.osgi-mock.junit5</artifactId>
            <version>3.5.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.testing.osgi-mock</artifactId>
            <version>3.5.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.jackrabbit.usermanager</artifactId>
            <version>2.2.26</version>
            <scope>test</scope>
        </dependency>
        <!-- pin version to override older oak transitively brought in by sling-mock -->
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-jcr</artifactId>
            <version>1.40.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.auth.core</artifactId>
            <version>1.2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.api</artifactId>
            <version>2.4.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.jackrabbit</groupId>
            <artifactId>oak-auth-external</artifactId>
            <version>1.40.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.jcr.resource</artifactId>
            <version>3.0.18</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.jaas</artifactId>
            <version>1.0.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.16</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.15.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>1.17.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>6.0.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <!-- workaround for https://github.com/testcontainers/testcontainers-java/issues/11212 -->
                        <api.version>1.44</api.version>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <sling.http.port>${http.port}</sling.http.port>
                        <!-- workaround for https://github.com/testcontainers/testcontainers-java/issues/11212 -->
                        <api.version>1.44</api.version>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>slingfeature-maven-plugin</artifactId>
                <version>1.9.2</version>
                <extensions>true</extensions>
                <configuration>
                    <skipAddFeatureDependencies>true</skipAddFeatureDependencies>
                    <framework>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.framework</artifactId>
                        <version>7.0.5</version>
                    </framework>

                    <!--
                        Prepares a feature model aggregate that takes the following features from
                        the Sling Starter:
                        - nosample_base - the base Sling Starter
                        - oak_persistence_sns - SegmentNodeStore persistence for Oak
                        - composum - The Composum Nodes administration tool
                        Notably missing are the slingshot and starter samples
                     -->
                    <aggregates>
                        <aggregate>
                            <classifier>app</classifier>
                            <filesInclude>main.json</filesInclude>
                            <attach>false</attach>
                            <includeArtifact>
                                <groupId>org.apache.sling</groupId>
                                <artifactId>org.apache.sling.starter</artifactId>
                                <classifier>nosample_base</classifier>
                                <version>13</version>
                                <type>slingosgifeature</type>
                            </includeArtifact>
                            <includeArtifact>
                                <groupId>org.apache.sling</groupId>
                                <artifactId>org.apache.sling.starter</artifactId>
                                <classifier>oak_persistence_sns</classifier>
                                <version>13</version>
                                <type>slingosgifeature</type>
                            </includeArtifact>
                            <includeArtifact>
                                <groupId>org.apache.sling</groupId>
                                <artifactId>org.apache.sling.starter</artifactId>
                                <classifier>starter</classifier>
                                <version>13</version>
                                <type>slingosgifeature</type>
                            </includeArtifact>
                            <includeArtifact>
                                <groupId>org.apache.sling</groupId>
                                <artifactId>org.apache.sling.starter</artifactId>
                                <classifier>composum</classifier>
                                <version>13</version>
                                <type>slingosgifeature</type>
                            </includeArtifact>
                        </aggregate>
                    </aggregates>
                    <repositories>
                        <repository>
                            <includeClassifier>app</includeClassifier>
                        </repository>
                    </repositories>
                    <scans>
                        <scan>
                            <includeClassifier>app</includeClassifier>
                        </scan>
                    </scans>
                </configuration>
                <executions>
                    <execution>
                        <id>prepare-features</id>
                        <goals>
                            <goal>aggregate-features</goal>
                            <goal>analyse-features</goal>
                            <goal>attach-features</goal>
                        </goals>
                        <phase>prepare-package</phase>
                    </execution>
                    <execution>
                        <id>create-app-repository</id>
                        <goals>
                            <goal>repository</goal>
                        </goals>
                        <phase>package</phase>
                    </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>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-feature-launcher</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.sling</groupId>
                                    <artifactId>org.apache.sling.feature.launcher</artifactId>
                                    <version>1.2.4</version>
                                    <type>tar.gz</type>
                                    <!-- remove the version number from the unpacked folder -->
                                    <fileMappers>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                            <pattern>\Qorg.apache.sling.feature.launcher-1.2.4\E</pattern>
                                            <replacement>org.apache.sling.feature.launcher</replacement>
                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                    </fileMappers>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.sling</groupId>
                <artifactId>feature-launcher-maven-plugin</artifactId>
                <version>0.1.8</version>
                <configuration>
                    <launches>
                        <launch>
                            <id>sling-starter-oak-tar</id>
                            <skip>${skipITs}</skip>
                            <featureFile>${project.slingfeature.outputDirectory}/feature-app.json</featureFile>
                            <repositoryUrls>
                                <repositoryUrl>file://${project.build.directory}/artifacts</repositoryUrl>
                            </repositoryUrls>
                            <launcherArguments>
                                <!-- <vm-options>
                                    <value>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:3007</value>
                                </vm-options> -->
                                <frameworkProperties>
                                    <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port>
                                </frameworkProperties>
                            </launcherArguments>
                            <environmentVariables>
                                <IT_ENCRYPTION_PASSWORD>random</IT_ENCRYPTION_PASSWORD>
                            </environmentVariables>
                            <startTimeoutSeconds>${it.startTimeoutSeconds}</startTimeoutSeconds>
                        </launch>
                    </launches>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>start</goal>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <version>0.14</version>
                <configuration>
                    <excludes>
                        <exclude>keycloak-data/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
