<?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>de.muenchen.oss.wahllokalsystem.wls-common</groupId>
    <artifactId>parent</artifactId>
    <version>1.6.2</version>
    <name>wls-common</name>
    <packaging>pom</packaging>
    <description>Serviceübergreifende Aspekte</description>
    <url>${wls.github.url}</url>

    <licenses>
        <license>
            <name>MIT License</name>
        </license>
    </licenses>

    <properties>
        <java.version>17</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>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.boot.version>3.4.4</spring.boot.version>
        <spring.cloud.version>2024.0.1</spring.cloud.version>
        <maven.compiler.plugin.version>3.14.0</maven.compiler.plugin.version>
        <!-- Version muss mit der in den spring-boot-dependencies bereitgestellten Lombok-Version übereinstimmen -->
        <org.projectlombok.lombok.version>1.18.30</org.projectlombok.lombok.version>
        <org.projectlombok.mapstructbinding.version>0.2.0</org.projectlombok.mapstructbinding.version>
        <org.mapstruct.version>1.6.3</org.mapstruct.version>
        <wls.github.url>https://github.com/it-at-m/Wahllokalsystem</wls.github.url>
        <wls.github.scm.connection>scm:git:https://github.com/it-at-m/Wahllokalsystem.git</wls.github.scm.connection>
    </properties>

    <modules>
        <module>exception</module>
        <module>monitoring</module>
        <module>security</module>
        <module>testing</module>
        <module>swagger</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <!-- Import dependency management from Spring Cloud -->
                <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.mapstruct</groupId>
                <artifactId>mapstruct</artifactId>
                <version>${org.mapstruct.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <scm>
        <url>${wls.github.url}</url>
        <connection>${wls.github.scm.connection}</connection>
        <developerConnection>${wls.github.scm.connection}</developerConnection>
        <tag>wls-common/1.6.2</tag>
    </scm>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Central Portal Publishing Plugin -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <tokenAuth>true</tokenAuth>
                            <autoPublish>true</autoPublish>
                            <deploymentName>${project.groupId}:${project.version}</deploymentName>
                            <excludeArtifacts>
                                <artifact>monitoring</artifact>
                            </excludeArtifacts>
                        </configuration>
                    </plugin>
                    <!-- GPG plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <configuration>
                            <skip>${skipGpg}</skip>
                        </configuration>
                        <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>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>2.43.0</version>
                    <dependencies>
                        <dependency>
                            <groupId>de.muenchen.oss</groupId>
                            <artifactId>itm-java-codeformat</artifactId>
                            <version>1.0.9</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>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>3.6.0</version>
                    <configuration>
                        <configLocation>checkstyle.xml</configLocation>
                        <excludeGeneratedSources>true</excludeGeneratedSources>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>10.23.0</version>
                        </dependency>
                    </dependencies>
                </plugin>

                <!-- release specific plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>3.2.7</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version>0.7.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.lombok.version}</version>
                        </path>
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                    <compilerArgs>
                        <compilerArg>
                            -Amapstruct.defaultComponentModel=spring
                        </compilerArg>
                        <compilerArg>
                            -Amapstruct.unmappedTargetPolicy=ERROR
                        </compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                    <tagNameFormat>@{project.version}</tagNameFormat>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.11.2</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doclint>none</doclint>
                    <sourceFileIncludes>
                        <sourceFileInclude>**/*.java</sourceFileInclude>
                    </sourceFileIncludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <distributionManagement>
        <!-- Central Repository -->
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <developers>
        <developer>
            <name>MrSebastian</name>
            <organization>Landeshauptstadt München</organization>
            <url>https://github.com/MrSebastian</url>
            <roles>
                <role>initiator</role>
                <role>developer</role>
            </roles>
        </developer>
        <developer>
            <name>Nic12345678</name>
            <organization>Landeshauptstadt München</organization>
            <url>https://github.com/Nic12345678</url>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
        <developer>
            <name>dragonfly28</name>
            <organization>Landeshauptstadt München</organization>
            <url>https://github.com/dragonfly28</url>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
        <developer>
            <name>GerhardPx</name>
            <organization>Landeshauptstadt München</organization>
            <url>https://github.com/GerhardPx</url>
            <roles>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

</project>
