<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright © 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.gravitee</groupId>
        <artifactId>gravitee-parent</artifactId>
        <version>23.5.0</version>
    </parent>

    <groupId>io.gravitee.common</groupId>
    <artifactId>gravitee-common</artifactId>
    <version>5.2.0</version>

    <name>Gravitee.io APIM - Common</name>

    <properties>
        <gravitee-bom.version>9.0.0</gravitee-bom.version>
        <java-uuid-generator.version>3.1.4</java-uuid-generator.version>
        <bouncycastle.version>1.84</bouncycastle.version>
        <bc-fips.version>2.1.2</bc-fips.version>
        <bcpkix-fips.version>2.1.10</bcpkix-fips.version>
        <bcutil-fips.version>2.1.6</bcutil-fips.version>
        <nimbus-jose-jwt.version>9.48</nimbus-jose-jwt.version>
        <freemarker.version>2.3.34</freemarker.version>
        <gravitee-gateway-api.version>6.0.0</gravitee-gateway-api.version>
        <awaitability.version>4.3.0</awaitability.version>
        <jmh-core.version>1.37</jmh-core.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Import bom to properly inherit all dependencies -->
            <dependency>
                <groupId>io.gravitee</groupId>
                <artifactId>gravitee-bom</artifactId>
                <version>${gravitee-bom.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

        <dependency>
            <groupId>io.gravitee.gateway</groupId>
            <artifactId>gravitee-gateway-api</artifactId>
            <version>${gravitee-gateway-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-rx-java3</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- UUID generator -->
        <dependency>
            <groupId>com.fasterxml.uuid</groupId>
            <artifactId>java-uuid-generator</artifactId>
            <version>${java-uuid-generator.version}</version>
        </dependency>

        <!-- Bouncy Castle: both non-FIPS and FIPS artifacts are declared as provided so this module compiles
             against either. At runtime, the consuming application puts only the relevant jars (FIPS or
             non-FIPS) on the classpath depending on whether it runs in FIPS mode. -->
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bc-fips</artifactId>
            <version>${bc-fips.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-fips</artifactId>
            <version>${bcpkix-fips.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcutil-fips</artifactId>
            <version>${bcutil-fips.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>${nimbus-jose-jwt.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <!-- Templating -->
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>${freemarker.version}</version>
        </dependency>

        <!-- Unit Tests -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <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>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <version>${awaitability.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>${jmh-core.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- bcprov-jdk18on/bcpkix-jdk18on (non-FIPS) and bc-fips/bcpkix-fips/bcutil-fips both implement
                 the org.bouncycastle.crypto.* packages under different signers, so the JVM refuses to load
                 both variants in the same classpath (SecurityException: signer information does not match).
                 KeyStoreUtilsFipsTest therefore runs as its own Surefire execution, on a classpath from which
                 the non-FIPS jars are excluded, and KeyStoreUtils.FIPS_MODE (a static final field evaluated
                 once per JVM) is set by registering BCFIPS before anything else in that run touches it. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <configuration>
                            <excludes>
                                <exclude>**/KeyStoreUtilsFipsTest.java</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>fips-test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/KeyStoreUtilsFipsTest.java</include>
                            </includes>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>org.bouncycastle:bcprov-jdk18on</classpathDependencyExclude>
                                <classpathDependencyExclude>org.bouncycastle:bcpkix-jdk18on</classpathDependencyExclude>
                                <classpathDependencyExclude>org.bouncycastle:bcutil-jdk18on</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
