<?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.3</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>de.muenchen.oss</groupId>
    <artifactId>xjustiz</artifactId>
    <version>0.0.8</version>
    <packaging>pom</packaging>

    <name>xjustiz</name>
    <description>Spring boot parent project to generate https://xjustiz.justiz.de messages.</description>
    <url>https://github.com/it-at-m/xjustiz-starter</url>

    <licenses>
        <license>
            <name>MIT</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url>https://github.com/it-at-m/xjustiz.git</url>
        <connection>scm:git:https://github.com/it-at-m/xjustiz.git</connection>
        <developerConnection>scm:git:https://github.com/it-at-m/xjustiz.git</developerConnection>
        <tag>xjustiz-0.0.8</tag>
    </scm>

    <modules>
        <module>xjustiz-converter</module>
        <module>xjustiz-starter</module>
    </modules>

    <developers>
        <developer>
            <organization>it@M</organization>
            <email>opensource@muenchen.de</email>
            <url>https://github.com/it-at-m</url>
        </developer>
    </developers>

    <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.1</logstash-logback-encoder.version>

        <!-- Linting & Formatting -->
        <spotless-maven-plugin.version>2.44.5</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.13</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.9</springdoc-openapi.version>

        <!-- Spotless P2 Mirror configuration (e.g. required when using company internal registry -->
        <p2.username /> <!-- must be empty, override via Maven settings.xml if needed -->
        <p2.password /> <!-- must be empty, override via Maven settings.xml if needed -->
        <p2.mirror>download.eclipse.org</p2.mirror>

        <!-- Others -->
        <lombok.version>1.18.36</lombok.version>
        <mockito.version>5.14.2</mockito.version>
        <central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>

    </properties>

    <dependencyManagement>
        <dependencies>

            <!-- 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.13.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <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.springframework.boot</groupId>
                            <artifactId>spring-boot-configuration-processor</artifactId>
                        </path>
                        <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>
                    <showDeprecation>true</showDeprecation>
                    <failOnWarning>true</failOnWarning>
                </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>
            <plugin>
                <groupId>org.cyclonedx</groupId>
                <artifactId>cyclonedx-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <configuration>
                            <projectType>library</projectType>
                            <outputName>library.cdx</outputName>
                            <skipNotDeployed>false</skipNotDeployed>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Testing -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>
                        @{argLine} -Dfile.encoding=${project.build.sourceEncoding}
                        -javaagent:${settings.localRepository}/org/mockito/mockito-core/${mockito.version}/mockito-core-${mockito.version}.jar
                        -Xshare:off
                    </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>

            <!-- Linting -->
            <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>
                            <p2Mirrors>
                                <p2Mirror>
                                    <prefix>https://download.eclipse.org</prefix>
                                    <url>https://${p2.username}:${p2.password}@${p2.mirror}</url>
                                </p2Mirror>
                            </p2Mirrors>
                        </eclipse>
                        <trimTrailingWhitespace />
                        <endWithNewline />
                        <importOrder />
                        <removeUnusedImports />
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <version>${pmd-maven-plugin.version}</version>
                <configuration>
                    <failOnViolation>false</failOnViolation>
                    <verbose>true</verbose>
                    <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>
                        </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>

</project>
