<?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>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.2</version>
        <relativePath />
    </parent>

    <groupId>de.muenchen.refarch</groupId>
    <artifactId>refarch-integrations</artifactId>
    <name>refarch-integrations</name>
    <description>Collection of different ready to use RefArch integrations</description>
    <url>https://github.com/it-at-m/refarch</url>
    <version>1.3.5</version>
    <packaging>pom</packaging>

    <modules>
        <module>refarch-s3-integration</module>
        <module>refarch-email-integration</module>
        <module>refarch-dms-integration</module>
        <module>refarch-cosys-integration</module>
        <module>refarch-address-integration</module>
    </modules>

    <properties>
        <!-- Compilation -->
        <java.version>21</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.release>${java.version}</maven.compiler.release>

        <!-- Logging -->
        <logstash-logback-encoder.version>8.0</logstash-logback-encoder.version>

        <!-- Linting & Formatting -->
        <spotless-maven-plugin.version>2.34.0</spotless-maven-plugin.version>
        <itm-java-codeformat.version>1.0.10</itm-java-codeformat.version>
        <pmd-maven-plugin.version>3.26.0</pmd-maven-plugin.version>

        <!-- Release -->
        <central-publishing-maven-plugin.version>0.5.0</central-publishing-maven-plugin.version>
        <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>

        <!-- Testing -->
        <jacoco.version>0.8.12</jacoco.version>

        <!-- Utility -->
        <mapstruct.version>1.6.3</mapstruct.version>
        <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
        <refarch-tools.version>1.1.0</refarch-tools.version>

        <!-- Additional required dependencies -->
        <springdoc-openapi.version>2.8.4</springdoc-openapi.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Open API -->
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
                <version>${springdoc-openapi.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
                <version>${springdoc-openapi.version}</version>
            </dependency>

            <!-- Logging -->
            <dependency>
                <groupId>net.logstash.logback</groupId>
                <artifactId>logstash-logback-encoder</artifactId>
                <version>${logstash-logback-encoder.version}</version>
            </dependency>

            <!-- Testing -->
            <dependency>
                <groupId>org.wiremock</groupId>
                <artifactId>wiremock-standalone</artifactId>
                <version>3.12.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${mapstruct.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Build -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${mapstruct.version}</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>${lombok-mapstruct-binding.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <doclint>accessibility,html,reference,syntax</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Testing -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- Release -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>

            <!-- Codeformatter Spotless -->
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>${spotless-maven-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>de.muenchen.oss</groupId>
                        <artifactId>itm-java-codeformat</artifactId>
                        <version>${itm-java-codeformat.version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <java>
                        <includes>
                            <include>src/main/java/**/*.java</include> <!-- Check application code -->
                            <include>src/test/java/**/*.java</include> <!-- Check application tests code -->
                        </includes>
                        <eclipse>
                            <file>itm-java-codeformat/java_codestyle_formatter.xml</file>
                        </eclipse>
                        <trimTrailingWhitespace />
                        <endWithNewline />
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Linting -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${pmd-maven-plugin.version}</version>
                <configuration>
                    <minimumTokens>100</minimumTokens>
                    <targetJdk>${java.version}</targetJdk>
                    <printFailingErrors>true</printFailingErrors>
                    <linkXRef>false</linkXRef>
                    <includeTests>true</includeTests>
                    <excludeRoots>
                        <excludeRoot>target/generated</excludeRoot>
                        <excludeRoot>target/generated-sources</excludeRoot>
                        <excludeRoot>target/generated-test-sources</excludeRoot>
                    </excludeRoots>
                    <rulesets>
                        <ruleset>refarch-pmd-ruleset.xml</ruleset>
                    </rulesets>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                            <goal>cpd-check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>de.muenchen.refarch.tools</groupId>
                        <artifactId>refarch-pmd</artifactId>
                        <version>${refarch-tools.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Central Portal Publishing Plugin -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <autoPublish>true</autoPublish>
                            <deploymentName>${project.groupId}:${project.artifactId}:${project.version}</deploymentName>
                            <excludeArtifacts>
                                <!-- Exclude services -->
                                <artifact>refarch-s3-integration-rest-service</artifact>
                            </excludeArtifacts>
                        </configuration>
                    </plugin>
                    <!-- GPG plugin -->
                    <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>
                                    <!-- Prevent `gpg` from using pinentry programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <scm>
        <url>https://github.com/it-at-m/refarch.git</url>
        <connection>scm:git:https://github.com/it-at-m/refarch.git</connection>
        <developerConnection>scm:git:https://github.com/it-at-m/refarch.git</developerConnection>
        <tag>refarch-integrations-1.3.5</tag>
    </scm>
    <licenses>
        <license>
            <name>MIT</name>
        </license>
    </licenses>
    <developers>
        <developer>
            <organization>it@M</organization>
            <email>opensource@muenchen.de</email>
            <url>https://github.com/it-at-m</url>
        </developer>
    </developers>
</project>
