<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>dev.fitko.fitconnect.sdk</groupId>
    <artifactId>sdk-java</artifactId>
    <version>3.2.0</version>
    <packaging>pom</packaging>

    <name>FIT-Connect Java-SDK</name>
    <description>Client library that interacts with the FIT-Connect REST-API</description>
    <url>https://git.fitko.de/fit-connect/sdk-java</url>

    <licenses>
        <license>
            <name>EUPL-1.2</name>
            <url>https://joinup.ec.europa.eu/page/eupl-text-11-12</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>Apache-2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>CC0-1.0</name>
            <url>https://creativecommons.org/publicdomain/zero/1.0/deed.en</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>FIT-Connect Contributors</name>
            <email>fit-connect@fitko.de</email>
            <organization>FITKO</organization>
            <organizationUrl>https://www.fitko.de</organizationUrl>
        </developer>
    </developers>

    <modules>
        <module>client</module>
    </modules>

    <scm>
        <connection>scm:git:https://git.fitko.de/fit-connect/sdk-java</connection>
        <developerConnection>scm:git:https://git.fitko.de/fit-connect/sdk-java</developerConnection>
        <url>https://git.fitko.de/fit-connect/sdk-java</url>
    </scm>

    <properties>

        <java.version>11</java.version>
        <maven.compiler.release>11</maven.compiler.release>

        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
        <project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>

        <!-- FIT-Connect dependencies -->
        <jwk-validator.version>2.3.1</jwk-validator.version>

        <!-- 3rd party dependencies -->
        <slf4j.version>2.0.17</slf4j.version>
        <nimbus.version>10.8</nimbus.version>
        <logback.version>1.5.32</logback.version>
        <lombok.version>1.18.44</lombok.version>
        <snakeyaml.version>2.6</snakeyaml.version>
        <okhttp.version>5.0.0-alpha.14</okhttp.version>
        <jackson-databind.version>2.21.1</jackson-databind.version>
        <jackson-annotations.version>2.21</jackson-annotations.version>
        <json-schema-validator.version>2.0.1</json-schema-validator.version>

        <!-- Testing -->
        <junit.version>5.14.3</junit.version>
        <junit-platform-version>1.14.3</junit-platform-version>
        <mockito.version>5.23.0</mockito.version>
        <wiremock.version>3.13.2</wiremock.version>
        <hamcrest.version>1.3</hamcrest.version>
        <testcontainers.version>1.21.4</testcontainers.version>

        <!-- Plugins -->
        <maven-surefire-plugin.version>3.5.5</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>3.5.5</maven-failsafe-plugin.version>
        <maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <maven-central-publishing-plugin.version>0.10.0</maven-central-publishing-plugin.version>
        <maven-git-commit-id-plugin.version>9.0.2</maven-git-commit-id-plugin.version>
        <maven-jacoco-plugin.version>0.8.14</maven-jacoco-plugin.version>
        <maven-sort-pom-plugin.version>4.0.0</maven-sort-pom-plugin.version>
        <maven-spotless-plugin.version>2.46.1</maven-spotless-plugin.version>

        <!-- Used for BuildInfo/Commit-ID for local builds -->
        <local-version-suffix>-local</local-version-suffix>

    </properties>

    <dependencyManagement>
        <dependencies>

            <!-- Module Dependencies -->
            <dependency>
                <groupId>dev.fitko.fitconnect.sdk</groupId>
                <artifactId>client</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>dev.fitko.fitconnect.sdk</groupId>
                <artifactId>examples</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>dev.fitko.fitconnect.sdk</groupId>
                <artifactId>integration-tests</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- FIT-Connect dependencies -->
            <dependency>
                <groupId>dev.fitko.fitconnect</groupId>
                <artifactId>jwkvalidator</artifactId>
                <version>${jwk-validator.version}</version>
            </dependency>

            <!-- 3rd Party Dependencies -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson-annotations.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson-databind.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jsr310</artifactId>
                <version>${jackson-databind.version}</version>
            </dependency>
            <dependency>
                <groupId>com.networknt</groupId>
                <artifactId>json-schema-validator</artifactId>
                <version>${json-schema-validator.version}</version>
            </dependency>
            <dependency>
                <groupId>com.nimbusds</groupId>
                <artifactId>nimbus-jose-jwt</artifactId>
                <version>${nimbus.version}</version>
            </dependency>
            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>okhttp</artifactId>
                <version>${okhttp.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-suite-engine</artifactId>
                <version>${junit-platform-version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.yaml</groupId>
                <artifactId>snakeyaml</artifactId>
                <version>${snakeyaml.version}</version>
            </dependency>
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
                <scope>provided</scope>
            </dependency>

            <!-- Testing -->
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${logback.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.wiremock</groupId>
                <artifactId>wiremock</artifactId>
                <version>${wiremock.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.squareup.okhttp3</groupId>
                <artifactId>mockwebserver</artifactId>
                <version>${okhttp.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-all</artifactId>
                <version>${hamcrest.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.testcontainers</groupId>
                <artifactId>testcontainers</artifactId>
                <version>${testcontainers.version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.ekryd.sortpom</groupId>
                <artifactId>sortpom-maven-plugin</artifactId>
                <version>${maven-sort-pom-plugin.version}</version>
                <configuration>
                    <nrOfIndentSpace>4</nrOfIndentSpace>
                    <createBackupFile>false</createBackupFile>
                    <expandEmptyElements>false</expandEmptyElements>
                    <sortDependencies>scope,groupId,artifactId</sortDependencies>
                    <sortDependencyManagement>scope,groupId,artifactId</sortDependencyManagement>
                    <sortPlugins>groupId,artifactId</sortPlugins>

                    <verifyFail>warn</verifyFail>
                    <verifyFailOn>strict</verifyFailOn>
                </configuration>
                <executions>
                    <execution>
                        <id>verify-pom.xml-is-sorted</id>
                        <goals>
                            <!-- Run ./mvnw sortpom:sort to sort the pom.xml -->
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>${maven-git-commit-id-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${maven-spotless-plugin.version}</version>
                <configuration>
                    <!-- optional: limit format enforcement to just the files changed by this feature branch -->
                    <formats>
                        <!-- you can define as many formats as you want, each is independent -->
                        <format>
                            <!-- define the files to apply to -->
                            <includes>
                                <include>.gitattributes</include>
                                <include>.gitignore</include>
                            </includes>
                            <!-- define the steps to apply to those files -->
                            <trimTrailingWhitespace/>
                            <endWithNewline/>
                            <indent>
                                <tabs>true</tabs>
                                <spacesPerTab>4</spacesPerTab>
                            </indent>
                        </format>
                    </formats>
                    <!-- define a language-specific format -->
                    <java>
                        <palantirJavaFormat>
                            <style>PALANTIR</style>
                            <formatJavadoc>false</formatJavadoc>
                        </palantirJavaFormat>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <id>apply-codestyle-on-validate</id>
                        <goals>
                            <goal>apply</goal>
                        </goals>
                        <phase>validate</phase>
                    </execution>
                    <execution>
                        <id>check-codestyle-on-compile</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                    <execution>
                        <id>check-codestyle-on-test</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven-failsafe-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <argLine>--illegal-access=permit</argLine>
                    <testFailureIgnore>false</testFailureIgnore>
                    <forkCount>2</forkCount>
                    <reuseForks>true</reuseForks>
                    <argLine>${surefireArgLine}</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${maven-jacoco-plugin.version}</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.80</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <phase>test</phase>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <failOnError>false</failOnError>
                    <additionalOptions>-Xdoclint:all -Xdoclint:-missing</additionalOptions>
                    <additionalJOptions>
                        <additionalJOption>-Xdoclint:all</additionalJOption>
                        <additionalJOption>-Xdoclint:-missing</additionalJOption>
                    </additionalJOptions>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- maven deployment -->
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>${maven-central-publishing-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>integration-tests</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>integration-tests</module>
            </modules>
        </profile>
        <profile>
            <id>examples</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>examples</module>
            </modules>
        </profile>
        <profile>
            <id>gpg-sign</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <useAgent>true</useAgent>
                                    <passphrase>$GPG_ENCRYPTION_KEY</passphrase>
                                    <gpgArguments>
                                        <arg>--batch</arg>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
