<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.gematik.demis</groupId>
    <artifactId>service-base</artifactId>
    <version>2.7.2</version>
    <name>service-base</name>
    <description>library implementing some cross-cutting concerns like error handling for spring boot services</description>
    <url>https://github.com/gematik/DEMIS-service-base</url>

    <licenses>
        <license>
            <name>Licensed under the EUPL 1.2</name>
            <url>https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12</url>
        </license>
    </licenses>

    <properties>
        <version.maven.javadoc>3.11.3</version.maven.javadoc>
        <version.maven-compiler-plugin>3.14.0</version.maven-compiler-plugin>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>

        <java.version>21</java.version>
        <spring-boot.version>3.5.6</spring-boot.version>
        <spring-cloud.version>2025.0.0</spring-cloud.version>
        <aspectj.version>1.9.24</aspectj.version>
        <springdoc.version>2.8.13</springdoc.version>
        <logstash-logback-encoder.version>8.1</logstash-logback-encoder.version>
        <ospo-resources.version>1.3.0</ospo-resources.version>
        <jacoco.plugin.version>0.8.13</jacoco.plugin.version>
        <fmt.maven.plugin.version>2.29</fmt.maven.plugin.version>
        <license-maven.plugin.version>2.6.0</license-maven.plugin.version>
        <maven-surefire.plugin.version>3.5.4</maven-surefire.plugin.version>
        <maven-gpg.plugin.version>3.2.8</maven-gpg.plugin.version>
        <maven-source.plugin.version>3.3.1</maven-source.plugin.version>
        <nexus-staging-maven.plugin.version>1.7.0</nexus-staging-maven.plugin.version>
        <central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
    </properties>

    <dependencies>
        <!-- Transitive required dependencies -->
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>net.logstash.logback</groupId>
            <artifactId>logstash-logback-encoder</artifactId>
            <version>${logstash-logback-encoder.version}</version>
        </dependency>

        <!-- Optional dependencies -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-micrometer</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${aspectj.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
            <optional>true</optional>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-contract-wiremock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-observation-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-tracing-bridge-otel</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
                <version>${springdoc.version}</version>
            </dependency>
            <!--CVEs-->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.18.0</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.6.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <finalName>service-base</finalName>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license-maven.plugin.version}</version>
                <configuration>
                    <licenseName>eupl_v1_2</licenseName>
                    <inceptionYear>2025</inceptionYear>
                    <organizationName>gematik GmbH</organizationName>
                    <licenseResolver>classpath://copyright-header/eupl-license</licenseResolver>
                    <failOnMissingHeader>true</failOnMissingHeader>
                    <failOnNotUptodateHeader>true</failOnNotUptodateHeader>
                    <canUpdateCopyright>true</canUpdateCopyright>
                    <licensesOutputDirectory>${project.basedir}/third-party-licenses</licensesOutputDirectory>
                    <licensesOutputFile>${project.basedir}/third-party-licenses/licenses.xml</licensesOutputFile>
                    <forceDownload>false</forceDownload>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <excludes>
                        <exclude>**/generated/**</exclude>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>de.gematik</groupId>
                        <artifactId>ospo-resources</artifactId>
                        <version>${ospo-resources.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>download-licenses</id>
                        <goals>
                            <goal>download-licenses</goal>
                        </goals>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>update-file-header</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>check-file-header</id>
                        <goals>
                            <goal>check-file-header</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.maven-compiler-plugin}</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <release>${java.version}</release>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <!-- See Issue: https://github.com/spring-projects/spring-boot/issues/38541 -->
                    <!-- Upgrade guide SpringBoot 3.2 https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#parameter-name-retention -->
                    <parameters>true</parameters>
                    <encoding>UTF-8</encoding>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <release>${java.version}</release>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generate-code-coverage-report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.spotify.fmt</groupId>
                <artifactId>fmt-maven-plugin</artifactId>
                <version>${fmt.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>format-code</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>src/main/java</sourceDirectory>
                            <testSourceDirectory>src/test/java</testSourceDirectory>
                            <verbose>false</verbose>
                            <filesNamePattern>.*\.java</filesNamePattern>
                            <skip>false</skip>
                            <skipSortingImports>false</skipSortingImports>
                            <style>google</style>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire.plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.jasig.maven</groupId>
                <artifactId>notice-maven-plugin</artifactId>
                <version>2.0.0</version>
                <configuration>
                    <noticeTemplate>NOTICE.template</noticeTemplate>
                    <outputDir>.</outputDir>
                </configuration>
                <executions>
                    <execution>
                        <id>notice-generation</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>releases</id>
            <url>${releaseDeploymentRepository}</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <url>${snapshotDeploymentRepository}</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>external</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>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </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</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${version.maven.javadoc}</version>
                        <configuration>
                            <doclint>none</doclint>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <scm>
        <url>https://github.com/gematik/DEMIS-service-base</url>
        <connection>scm:git:git://github.com/gematik/DEMIS-service-base.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:gematik/DEMIS-service-base.git</developerConnection>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/gematik/DEMIS-service-base</url>
    </issueManagement>

    <organization>
        <name>gematik GmbH</name>
        <url>https://www.gematik.de</url>
    </organization>

    <developers>
        <developer>
            <name>gematik</name>
            <email>software-development@gematik.de</email>
            <url>https://gematik.github.io/</url>
            <organization>gematik GmbH</organization>
            <organizationUrl>https://www.gematik.de/</organizationUrl>
        </developer>
    </developers>
</project>
